A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/HTMLElement/selectedIndex below:

selectedIndex · WebPlatform Docs

selectedIndex

Property of dom/HTMLElementdom/HTMLElement

Syntax
var result = element.selectedIndex;
element.selectedIndex = value;
Examples

This example uses the selectedIndex property to retrieve individual values from a select object. When a site is selected from the list, the browser displays the associated page.

<SELECT onchange="window.location.href=this.options
    [this.selectedIndex].value">
<OPTION VALUE="http://www.microsoft.com/ie">
    Internet Explorer</OPTION>
<OPTION VALUE="http://www.microsoft.com">
    Microsoft Home</OPTION>
<OPTION VALUE="http://msdn.microsoft.com">
    Developer Network</OPTION>
</SELECT>
Notes Remarks

Options in a select object are indexed in the order in which they are defined, starting with an index of 0. When you set the selectedIndex property, the display of the select object updates immediately. The selectedIndex property returns -1 if a select object does not contain any selected items. Setting the selectedIndex property clears any existing selected items. The selectedIndex property is most useful when used with select objects that support selecting only one item at a time—that is, those in which the MULTIPLE attribute is not specified. If the MULTIPLE attribute is specified for a select object, the selectedIndex property returns only the index of the first selected item, if any. The selected property is most useful when used with select objects that support selecting more than one item at a time—that is, those in which the MULTIPLE attribute is specified. You can use the selected property to determine whether an individual item in a select object is selected. In addition, selected items are not cleared when the selected property is set. This allows multiple items in the list to be selected at the same time.

Syntax Standards information See also Related pages Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4