Click to See Complete Forum and Search --> : JS and setting selection box
hpl
Feb 7th, 2003, 05:55 AM
I have a selection box with different ID. I save the data from this in a database using request.form(name of selection). My problem is that I wish to load the saved content to the webpage. How can I set the Selection when I have the ID? I can not use .selectedIndex because this is not related to the ID.
Rick Bull
Feb 7th, 2003, 06:38 AM
I'm not sure if I've understood you properly, or if there is a quicker way to do it, but I'd use a loop. Try this for example:
<select onchange="for (var loopCounter = 0; loopCounter < this.length; loopCounter++) { if (this.options[loopCounter].id==['a']) { this.options[loopCounter].selected = true; break; } }">
<option>1</option>
<option id="a">2</option>
<option>3</option>
</select>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.