August 1999
Intermediate to advanced
1488 pages
72h 53m
English
select.options.selectedIndex
The selectedIndex property of the options array of the Select object returns the index number of the selected option in that instance of a select box.
Listing 7.475 has a single select box. When the user makes a selection, the onChange event handler is used to pop up an alert box that displays the index number of the selected option in this select box.
<form name="myForm"> <select name="mySelect" onChange='alert(mySelect.options.selectedIndex)'> <option value=HOCK>Hockey</option> <option value=RUG>Rugby</option> ... |
Read now
Unlock full access