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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option question

Status
Not open for further replies.

flnMichael

Programmer
Nov 13, 2003
96
US
Hey,
I know this may be a stupid question, and maybe I'm overlooking the obvious, but I'm still a little stumped.

This is the code I have right now:

<select name=leak_list style=display:none>
<option selected value=0>Select Leak Location</option>
<option value='Upper Area'>Upper Area</option>
<option value='Lower Area'>Lower Area</option>
<option value='Middle Area'>Middle Area</option>
etc...
</select></td>

What I need from this is the value along with the appropriate index associated with the choice. Now, I know I can say the value=1,2,3 but I need the 'Upper Area' to go to the next page. The thing is that I generate the list from vbscript function I use, so the value may change at any time based on a file I feed into it, so the list may have 2 options or 15 depending on what page I use. Is there a way I can index the option without changing the current code?

Thanks
Mike
 
Yeah. With JavaScript, the following will give you the Index of the option that is selected.

[tt]document.form_name.leak_list.selectedIndex[/tt]

or

[tt]this.selectedIndex[/tt]

depending on where you're referencing the object.

Hope this helps.

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
see, I knew it was a simple fix...Works just fine. THANKS!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top