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

How do I retrieve id values from <option id=123> ?

Status
Not open for further replies.

DoTheLoop

Programmer
Sep 12, 2003
14
SE
Hia!

I have a problem with select box. I have to put alot of info on each <option> in a selectbox.

Looking something like this:

<select name=whatever>
<option value=1 id=1234>Some text</option>
<option value=2 id=5678>Some other text</option>
etc....
</select>

Is there some easy way to retrieve this id value?

Regards
DoTheLoop
 
Code:
var s = document.formName.selectListName;
var sid = s.options[s.selectedIndex].id;

...sid will hold the value you seek.

'hope that helps.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top