Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add new option drop down list dynamically

Status
Not open for further replies.

flyclassic22

Technical User
Oct 1, 2002
54
SG
how do i add new option to a existing dropdown list dynamically using asp?
 
You can easily do that with javascript.
Copy the file below and test it.

...........................................................

<html>
<head>
<title>Dynamic Combos</title></head><body>
<!--
script provided freely by -->
<h3>Select Author</h3>
<form action=&quot; method=&quot;get&quot;>
<select name=&quot;myChoice&quot; onchange=&quot;if(this.options[this.selectedIndex].text=='Other'){var c=prompt('Enter your Choice','');if(c!=''){this.add(new Option(c));this.selectedIndex=this.length-1;}}&quot;>
<option>Mark Twain</option>
<option selected>Micheal Crichton</option>
<option>Stephen King</option>
<option>Tanwani Anyangwe</option>
<option>Ian Fleming</option>
<option>Other</option>
</select>
<input type=&quot;submit&quot; value=&quot;Go&quot; />
</form>
</body>
</html>

............................................................ Build web applications faster with a few lines of XML Code using DataML[tm]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top