ZVON > References > DOM2 Reference

selectedIndex (attribute )

Owning interface and usage:  
HTMLSelectElement.selectedIndex

Member of these other interfaces:  
none

Readonly:   no

Type:   long

Description:  
The ordinal index of the selected option, starting from 0. The value -1 is returned if no element is selected. If multiple options are selected, the index of the first selected option is returned.


Example:
Source:
   <SELECT id="component-select">
      <OPTION value="Component_1_a">Component_1</OPTION>
      <OPTION value="Component_1_b">Component_2</OPTION>
      <OPTION value="Component_2_a" selected="selected">Component_3</OPTION>
      <OPTION value="Component_2_b">Component_4</OPTION>
   </SELECT>
JavaScript:
  function showSelectedIndex() {
    var main = document.getElementById('component-select');
    alert('Selected option has index nr. '+main.selectedIndex);
  }
Try it:  
See it: