August 1999
Intermediate to advanced
1488 pages
72h 53m
English
select.selectedIndex
The selectedIndex property of the Select object returns the index number of the selected option in that instance of a select box. If this property is used to access a multiple select box, it will return the index number of the first selected item.
Listing 7.477 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.selectedIndex)'> <option value=HOCK>Hockey</option> ... |
Read now
Unlock full access