Click to return to the Reusing Browser Technology home page    
IHTMLSelectElement::get_o...     IHTMLSelectElement::get_s...     IHTMLSelectElement Interf...    
Web Workshop  |  Reusing Browser Technology

IHTMLSelectElement::get_selectedIndex Method


Retrieves the index of the item selected from the list box or drop-down list associated with the SELECT object.

Syntax

HRESULT get_selectedIndex(
    long *p 
);

Parameters

p
Address of a long variable that receives the index of the selected item.

Return Value

Returns S_OK if successful, or an error code otherwise.

Remarks

Options in a SELECT object are indexed in the order in which they are defined, starting with an index of 0. You can set the selectedIndex property at any time. The display of the SELECT object updates immediately when you set the selectedIndex property. Both forms of the syntax specify the same value.

In general, the selectedIndex property is more useful for SELECT objects that are created without the multiple attribute. If you evaluate selectedIndex when multiple options are selected, the selectedIndex property specifies the index of the first option only. Setting selectedIndex clears any other options that are chosen in the SELECT object.

The selected property of the SELECT object's options array is more useful for SELECT objects that are created with the multiple attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

Windows CE

Windows CE Use version 2.12 and later
Minimum availability Internet Explorer 4.0

IHTMLSelectElement::put_selectedIndex Method


Sets the index of the item selected from the list box or drop-down list associated with the SELECT object.

Syntax

HRESULT put_selectedIndex(
    long v 
);

Parameters

v
Long value that specifies the zero-based index of the item to set.

Return Value

Returns S_OK if successful, or an error code otherwise.

Remarks

Options in a SELECT object are indexed in the order in which they are defined, starting with an index of 0. You can set the selectedIndex property at any time. The display of the SELECT object updates immediately when you set the selectedIndex property. Both forms of the syntax specify the same value.

In general, the selectedIndex property is more useful for SELECT objects that are created without the multiple attribute. If you evaluate selectedIndex when multiple options are selected, the selectedIndex property specifies the index of the first option only. Setting selectedIndex clears any other options that are chosen in the SELECT object.

The selected property of the SELECT object's options array is more useful for SELECT objects that are created with the multiple attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

Windows CE

Windows CE Use version 2.12 and later
Minimum availability Internet Explorer 4.0


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.