Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list/menu that when a specific item is chosen, I need that to populate textbox 1, and then set the list/menu back to Select. Then from that original list/menu, the user needs to choose another option and have that populate textbox 2 and so on. Can someone show me how to do this via javascript?

Here is the code for the HTML:
XML
<select name="ddl11" id="ddl11" onChange="PopTextbox()">
       <option value="Select" selected>Select</option>
       <option value="Option 1">Option 1</option>
       <option value="Option 2">Option 2</option>
       <option value="Option 3">Option 3</option>
       <option value="Option 4">Option 4</option>
       <option value="Option 5">Option 5</option>
       <option value="Option 6">Option 6</option>
       <option value="Option 7">Option 7</option>
       <option value="Option 8">Option 8</option>
       <option value="Option 9">Option 9</option>
       <option value="Option 10">Option 10</option>
     </select>
   </p>
   <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
     <tr>
       <td width="75%" align="center" bgcolor="#BFD0EB"><strong>Name</strong></td>
     </tr>
     <tr>
       <td align="center"><label for="textfield1"></label>
       <input name="textfield1" type="text" id="textfield1" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield2" type="text" id="textfield2" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield3" type="text" id="textfield3" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield4" type="text" id="textfield4" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield5" type="text" id="textfield5" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield6" type="text" id="textfield6" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield7" type="text" id="textfield7" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield8" type="text" id="textfield8" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield9" type="text" id="textfield9" size="80"></td>
     </tr>
     <tr>
       <td align="center"><input name="textfield10" type="text" id="textfield10" size="80"></td>
     </tr>
   </table>
Posted

1 solution

You can't able to change the SelectedIndex inside change Event. So, you can't reset. Why would you need that? That is not a usual behaviour. User will get confused.

Demo


For your other requirements, see the demo - [Demo] Populate related TextBox on DropDownList Change[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900