Javascript Select Events
Javascript Select Events
<form name=tests>
<select name=sel>
<option value=test> test select option </option>
<option value=test2> test2</option>
</select>
</form>
Select DOM Property ,
Description & Example
length Used to get the length (total number of options) in
the select object
Ex .To Get the length:
var len = document.tests.sel.length;
Select DOM Property ,
Description & Example
selectedIndex selectedIndex is used to get or set the
position of the option selected
Ex. To Get:
var ss = document.tests.sel.selectedIndex;
Returns 1 if the second option is the selected one.
To Set SelectedIndex:
document.tests.sel.selectedIndex = 0;