View Full Version : how to get the field id from a dropdown list

07-10-2006, 01:56 AM
I populate a dropdown list with some values using javascript and after the user choose a value from the list he /she press a button to submit that value
for example "red"

I want to get the fild_id number for this value "red" and post it , how I can do that ?

please if you can supply few code snippets it helps much


07-10-2006, 02:06 AM
So you want to know which location the option was at, like first, second, third?

07-10-2006, 12:38 PM
no I know about selectedindex
I have the following table :

f_id color
1 red
2 blue
3 green

I want to get the f_id value of the selected color, how I can do that ?

07-10-2006, 04:30 PM
<form name="f">
<select name="s">
<option value="1">Red1</option>
<option value="2">Red2</option>
<option value="3">Red3</option>
<option value="4">Red4</option>

document.f.s.value will return the value of whatever is selected.