Javascript selectedIndex value
by Ramya[ Edit ] 2009-10-15 10:47:49
Javascript selectedIndex value:
Normal document.getElementById('selectbox id').selectedIndex returns only the index value of the options in selectbox.
To return selected index's value, we can use "document.formname.fieldname.value". In some cases it wont work in IE.
Hence use this method to return selectedIndex value which works both in firefox and ie,
var selectboxvalue = document.formname.fieldname.options[document.formname.fieldname.selectedIndex].text;
Variable "selectboxvalue" returns the selected index's value.