See also:  setOptionAttributes, setOptionText, setSelectedOption, setSelectedOptionByValue, setSelectedOptionByText, getSelectIndexByValue, getSelectIndexByText, getSelectOptionText, getSelectOptionValue

Function used to set the text of an option associated with a given SELECT object.

Syntax

JSV_setOptionValue(selectObj, optionIndex, optionValue)

Prototype

n/a

Returns

n/a

Parameters

The setOptionValue function uses the following arguments.

Argument Description
selectObj The SELECT object.
optionIndex An integer specifying the index of the selected option in a Select object.
optionValue Specifies a value that is returned to the server when the option is selected and the form is submitted.

Remarks

n/a

Dependencies

n/a

Example

The following lines of code

<FORM ACTION="setOptionValue.html" NAME="SelectTest" ID="SelectTest" onSubmit="return false;">
<SELECT NAME="ChangeSelect" ID="ChangeSelect" SIZE="1">
<OPTION VALUE="1" SELECTED>One</OPTION>
<OPTION VALUE="2">Two</OPTION>
<OPTION VALUE="3">Three</OPTION>
<OPTION VALUE="4">Four</OPTION>
<OPTION VALUE="5">Five</OPTION>
<OPTION VALUE="6">Six</OPTION>
</SELECT>
<INPUT TYPE="button"
       NAME="btnTest"
       VALUE="Change OPTION 3 Value to Three"
       CLASS="jsvButtons"
       onClick="performTest(this.form);">
</FORM>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function performTest(formObj) {
    alert( "Current value of OPTION 3: " + formObj.ChangeSelect.options[2].value );
    JSV_setOptionValue(formObj.ChangeSelect, 2, "Three");
    alert( "New value of OPTION 3: " + formObj.ChangeSelect.options[2].value );
}
</SCRIPT>

produce