|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a situation where I know the value of an option I want selected but not the index.
IE will allow me to select by setting options.value= the value I want, but Netscape doesn't allow this. I know the proper way is to set selectedIndex but I don't know the index. How can I get the index of the option from the value? |
|
#2
|
|||
|
|||
|
I'm not quite sure if I understand your problem... but if you want a certain option seleted by default, just use the SELECTED attribute of the OPTION tag:
<OPTION VALUE="01" SELECTED> But, if you want to get the selectedIndex, use this format: var eSelected = document.formname.select name.selectedIndex; and then this to get the value of the option that is selected. var eVarSelected = document.signup.selectengine.options[eSelected].value; Hope this helps you come up with a solution. HyperWhiz |
|
#3
|
|||
|
|||
|
If you know the value of the item you want selected, why not loop through the options, testing each value until you find what you want? The index where you find it will be the index that you need selected.
(Sorry, a little too late for a code example, I guess you can work it out from there (and if not, feel free to ask again)) Hope this helps, Ton |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > getting option index from option.value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|