Venkatagiri
asked on
Dynamically selecting an item as default in a drop-down menu
Is there a way to make different items in a drop-down menu as "selected" based on some previous information. It is easy to set one item as "selected" while writing HTML. Is there a way to do it dynamically using Java Script or VB Script?
... the above assumes this:
<FORM name='myform'>
<SELECT name='myselect'>
<OPTION></option>
...
</select>
</form>
<FORM name='myform'>
<SELECT name='myselect'>
<OPTION></option>
...
</select>
</form>
ASKER
The solution you presented works. But I have run into a problem for which, I wonder, if you have solution. The selectedIndex in my page is a VBScript variable. Is there a way to pass a VBScript variable to a JavaScript routine? Thanks for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help. Mine was an ASP VBScript value.
Your welcome, glad it worked!
<SCRIPT language='javascript'>
// the code below will select the 4th row in the list
document.myform.myselect.s
</script>
Let me know if you need more details.