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

Function used to select a specific option associated with a given SELECT object by specifying the value of the OPTION.

Syntax

JSV_setSelectedOptionByValue(selectObj, optionValue, compareCase)

Prototype

n/a

Returns

n/a

Parameters

The setSelectedOptionByValue function uses the following arguments.

Argument Description
selectObj The SELECT object.
optionValue Specifies a value that is returned to the server when the option is selected and the form is submitted.
compareCase Optional. Default is false--case insensitive comparison.

Remarks

n/a

Dependencies

n/a

Example

The following lines of code

<FORM ACTION="setSelectedOptionByValue.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="Select Option 5"
       CLASS="jsvButtons"
       onClick="performTest(this.form);">
</FORM>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function performTest(formObj) {
    JSV_setSelectedOptionByValue(formObj.ChangeSelect, "5", false);
}
</SCRIPT>

produce