<select> how to get id of selected item?

Hello experts!

I have <select> list populated dynamically:

<select id="feat1" name="feat1" title="feat1">
@foreach (var p in featQuery)
{
  counter=counter + 1;
  <option id="@counter">@p.Name</option>
}
</select>

How can I retrieve id number of option selected by user?

To get a option I use:

value = Request.Form["feat1"];

But I do not need string, I need id here.

Thank you

panJames
panJamesAsked:
Who is Participating?
 
cbtahir2001Commented:
Its really very simple. Try this Jazascript code

var x=document.getElementById("feat1").selectedIndex;
0
 
panJamesAuthor Commented:
Forgot to mention: it needs to work/ cooperate with WebMatrix code.

panJames
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.