473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

On select dropdown value how to display textbox

Hi

I am facing a problem with my code ....
this is what I am doing ...
I am running this dropdown in while loop...and i want when i select Cheque then display textbox otherwise textbox not display. but when i select Cheque on selection function work only for first row not working in other row.
I am attaching the code snippet as well ... see if you can help ...
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function handleOther(val){ 
  3. if(val == "Cheque"){ 
  4. document.getElementById('cheque_no').style.display = ''; 
  5. }else{                              document.getElementById('cheque_no').style.display = 'none'; }}</script>
Expand|Select|Wrap|Line Numbers
  1. <select name="paidmode[]" onChange="handleOther(this.value)">
  2. <option value="Cash">Cash</option><option value="Cheque">Cheque</option>
  3. </select>
  4. <input type="text" name="cheque_no[]" size="12" id="cheque_no">
Oct 29 '10 #1
1 3455
acoder
16,027 Expert Mod 8TB
That's because IDs are supposed to be unique. When you use document.getElementById() to get an element, it gets the first one that matches the ID.

Make all IDs unique (e.g. use the row number, cheque_no1, cheque_no2...) and then use that to get the correct element. Alternatively, you could get the collection (document.getElementsByName("cheque_no[]")) and then loop over them to find the correct element.
Nov 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
by: Monty | last post by:
I use a SELECT dropdown as the nav interface for jumping to a chosen page number. When I setup up the SELECT element on the page, I want to show the user the current page number they are on, so, I...
2
by: | last post by:
Hi everyone, I have a form with a combo box on it. When you select a value (a PO#) from the combo box, the bound field is the indexID of the selected PO. On the same form, I have a text box...
5
by: luanhoxung | last post by:
hi all!! i face to a new trouble. in my form, i have a textbox(unbound) that informs details of product when i choose the value of combo box(IDPro). it is ok when i choose the first value of...
2
by: Wolfgang | last post by:
Hi, is there a possibility to change the size of the select-dropdown-box ? I predefine the length of the option-area with 10 inside HTML as follows: <select class="select250"...
2
by: sureshRV | last post by:
Hi,How to convert Dropdown list as Textbox in runtime using C#
7
by: TechnoAtif | last post by:
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone...
6
by: idj | last post by:
Hi, I'm using the following code to redirect to a new page with a select dropdown, which works fine: <script type="text/javascript"> <!-- function go(){ location= document.FRM_NAME.VALUE_NAME....
0
acoder
by: acoder | last post by:
Problem The select object's add method doesn't append options to the end of the list. Browser Internet Explorer Example The Javascript code for appending an option element at the end of a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.