Javascript selectedIndex value - Javascript Views : 1665
Tagged in : Javascript
0 0
Send mail
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.

By Ramya, On - 2009-10-15



    Login to add Comments .