JavaScript Reference/Javascript Properties/index
"index" Example
<source lang="javascript">
<html> <body> <select id="myS" size=5>
<option id="o1">1</option> <option id="o2">2</option> <option id="o3">3</option> <option id="o4">4</option> <option id="o5">5</option>
</select> <input type="button" value="1" onClick="function1(o1);"> <input type="button" value="2" onClick="function1(o2);"> <input type="button" value="3" onClick="function1(o3);"> <input type="button" value="4" onClick="function1(o4);"> <input type="button" value="5" onClick="function1(o5);"> <script language="JavaScript">
function function1(elem) { alert("Index: "+ elem.index); }
</script> </body> </html>
</source>
"index" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<option> | +----------------+--------------------------------------------------------------+
</source>
"index" Syntax and Note
<source lang="javascript">
Note: Read and write property. Specifies the index number of <option> in a <select>.
Syntax:
document.getElementById("optionID").index = value document.all.optionID.index = value // IE only
</source>