Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Select options selectedIndex

The selectedIndex property returns the index number of the selected option in that instance of a select box. <html>     <form name="myForm">       <select name="mySelect" onChange='alert(mySelect.options.selectedIndex)'>         <option value=A>AA</option>         <option value=B>BB</option>         <option value=C>CC</option>         <option value=D>DD</option>     </select>     </form> </html>