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:



_____________________________________________
Reference Search | Sitemap | XML Glossary       ZVON | Systinet




Related sites:
  • dotNet Slackers - Your latest resource for ASP.NET
  • Dotnet Spider - Outsourcing and Offshore software development in India
  • XML - Xselerator, XSL Editor, BizTalk Utilities, XML Tutorials, Learn XML
  • Planet Source Code - The largest public source code database on the Internet
Domain Names conference call service UNLIMITED Web Hosting by HostDepartment Alojamiento Web answering service
MSN VoIP Internettelefonie Hosted Exchange, SDSL VoIP Internettelefonie AT VoIP Internettelefonie DE