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

Function used to determine the selected index.

Syntax

JSV_getSelectIndexByValue(selectObj, searchValue [, compareCase])

Prototype

n/a

Returns

The index of the OPTION with the designated value, or SELECTNOTEXISTS if the designated value could not be found.

Parameters

The getSelectIndexByValue function uses the following arguments.

Argument Description
selectObj The SELECT object.
searchValue Specifies an OPTION value that is to be searched for in designated SELECT object.
compareCase Optional. Default is false--case insensitive comparison.

Remarks

n/a

Dependencies

n/a

Example

The following lines of code

<FORM ACTION="getSelectIndexByValue.html" NAME="SelectTest" ID="SelectTest" onSubmit="return false;">
<SELECT NAME="ChangeSelect" ID="ChangeSelect" SIZE="1">
<OPTION VALUE="One" SELECTED>One</OPTION>
<OPTION VALUE="Two">Two</OPTION>
<OPTION VALUE="Three">Three</OPTION>
<OPTION VALUE="Four">Four</OPTION>
<OPTION VALUE="Five">Five</OPTION>
<OPTION VALUE="Six">Six</OPTION>
</SELECT>
<INPUT TYPE="button"
       NAME="btnTest"
       VALUE="Get Index of 'Five'"
       CLASS="jsvButtons"
       onClick="performTest(this.form);">
</FORM>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function performTest(formObj) {
    alert( "Selected Index: " + JSV_getSelectIndexByValue(formObj.ChangeSelect, "Five") );
}
</SCRIPT>

produce