August 1999
Intermediate to advanced
1488 pages
72h 53m
English
select.options.length
The length property of the options array of the Select object returns the number of options in that instance of a select box.
Listing 7.474 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 number of options in this select box.
<form name="myForm"> <select name="mySelect" onChange='alert(mySelect.options.length)'> <option value=HOCK>Hockey</option> <option value=RUG>Rugby</option> <option value=GOLF>Golf</option> <option value=TENNIS>Tennis</option> ... |
Read now
Unlock full access