IHTMLOptionElement

IHTMLOptionElement


This interface denotes one choice in a SELECT block.

This element is a block element.

IHTMLOptionElement Methods
put_selected   get_selected   put_value  
get_value   put_defaultSelected   get_defaultSelected  
put_index   get_index   put_text  
get_text   get_form  

IHTMLOptionElement::put_selected

HRESULT put_selected(
    VARIANT_BOOL v 
);

Indicates whether this item is the default.

v
Selected flag. Setting this parameter to TRUE selects the item; setting it to FALSE deselects it.

This attribute is used to determine whether a value is submitted with the form. If the value of the control matches the default value, the control's value is not submitted. The value is only submitted when the control's value does not match the default value. Therefore, changing this value changes the rule for whether the value is submitted with the form.

The first item is selected by default.

See also get_selected

IHTMLOptionElement::get_selected

HRESULT get_selected(
    VARIANT_BOOL *p 
);

Indicates whether this item is the default.

p
Address of a variable that receives TRUE if the item is the default, or FALSE if not.

This attribute is used to determine whether a value is submitted with the form. If the value of the control matches the default value, the control's value is not submitted. The value is only submitted when the control's value does not match the default value. Therefore, changing this value changes the rule for whether the value is submitted with the form.

The first item is selected by default.

See also put_selected

IHTMLOptionElement::put_value

HRESULT put_value(
    BSTR v 
);

Specifies the value of the given control. The value is submitted to the server as a name/value pair.

v
String specifying the value. It can be any valid string. The purpose of the string depends on the type of control, as described in the following table.
Control type Description
checkbox The "selected" value. The control submits this value only if the user has selected the control. Otherwise, the control submits no value.
file The value, a file name, typed by the user into the control. Unlike other controls, this value is read-only.
hidden The control submits this value when the form is submitted.
OPTION The "selected" value. The containing list box control submits this value only if the user has selected the option.
password The default value. The control displays this value when it is first created and when the user clicks the reset button.
radio The "selected" value. The control submits this value only if the user has selected the control. Otherwise, the control submits no value.
reset The button label. If not set, the label defaults to "Reset".
submit The button label. If not set, the label defaults to "Submit".
text The default value. The control displays this value when it is first created and when the user clicks the reset button.

See also get_value

IHTMLOptionElement::get_value

HRESULT get_value(
    BSTR *p 
);

Retrieves the value of the given control. The value is submitted to the server as a name/value pair.

v
Address of a variable that receives the value. It can be any valid string. The purpose of the string depends on the type of control, as described in the following table.
Control type Description
checkbox The "selected" value. The control submits this value only if the user has selected the control. Otherwise, the control submits no value.
file The value, a file name, typed by the user into the control. Unlike other controls, this value is read-only.
hidden The control submits this value when the form is submitted.
OPTION The "selected" value. The containing list box control submits this value only if the user has selected the option.
password The default value. The control displays this value when it is first created and when the user clicks the reset button.
radio The "selected" value. The control submits this value only if the user has selected the control. Otherwise, the control submits no value.
reset The button label. If not set, the label defaults to "Reset".
submit The button label. If not set, the label defaults to "Submit".
text The default value. The control displays this value when it is first created and when the user clicks the reset button.

See also put_value

IHTMLOptionElement::put_defaultSelected

HRESULT put_defaultSelected(
    VARIANT_BOOL v 
);

Specifies whether the option is selected by default.

v
Selection flag. TRUE selects the option; FALSE deselects it.

This value can be changed programmatically but has no effect on the appearance nor on how forms are submitted.

The default value for this property is TRUE.

See also get_defaultSelected

IHTMLOptionElement::get_defaultSelected

HRESULT get_defaultSelected(
    VARIANT_BOOL *p 
);

Determines whether the option is selected by default.

v
Address of a variable that receives TRUE if the option is selected by default, or FALSE if not.

This value can be changed programmatically but has no effect on the appearance nor on how forms are submitted.

The default value for this property is TRUE.

See also put_defaultSelected

IHTMLOptionElement::put_index

HRESULT put_index(
    LONG v 
);

Sets the ordinal position of the option in the list box.

v
Value specifying the ordinal position.

You can assign a value to this property without generating a syntax error, but the value is not stored.

See also get_index

IHTMLOptionElement::get_index

HRESULT get_index(
    LONG *p 
);

Retrieves the ordinal position of the option in the list box.

p
Address of a variable that receives the ordinal position.

You can assign a value to this property without generating a syntax error, but the value is not stored.

See also put_index

IHTMLOptionElement::put_text

HRESULT put_text(
    BSTR v 
);

Sets the text string specified by the OPTION tag.

v
String specifying the text.

Assigning a value to the text property changes the text property internally but does not cause the listed value to change. Submitting the form submits the internally stored value, not the one displayed.

See also get_text

IHTMLOptionElement::get_text

HRESULT get_text( 
    BSTR *p 
);

Retrieves the text string specified by the OPTION tag.

p
Address of a variable that receives the string.

Assigning a value to the text property changes the text property internally but does not cause the listed value to change. Submitting the form submits the internally stored value, not the one displayed.

See also put_text

IHTMLOptionElement::get_form

HRESULT get_form(
    IHTMLFormElement **p 
);

Retrieves a reference to the form the element is embedded on.

p
Address of a variable that receives an interface pointer to the form element. This parameter receives NULL if the element is not on a form.

See also IHTMLFormElement

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.