faqts : Computers : Programming : Languages : JavaScript : Forms : SELECT

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 18 people (56%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

i want to know the index number selected then what should i write?

Dec 21st, 2002 23:01
Jean-Bernard Valentaten, Narissa Bickhan, anuprita abhyankar,


By looking up the JavaScript DOM we learn that this is done the 
following way:
var index = ocument.formName.selectName.selectedIndex;
This will always return an integer value representing the index of the 
currently selected option, where the first option will be 0 and so on. 
If no option is selected it will return -1.
HTH,
Jean