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

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

Syntax

JSV_setOptionAttributes(selectObj, optionIndex, optionText [, optionValue])

Prototype

n/a

Returns

n/a

Parameters

The setOptionAttributes function uses the following arguments.

Argument Description
selectObj The SELECT object.
optionIndex The desired length of, or number of options associated with, the SELECT object. Default value is 1.
optionText Specifies the text to display in the select list.
optionValue Optional. Specifies a value that is returned to the server when the option is selected and the form is submitted. Default value is that specified in optionText.

Remarks

n/a

Dependencies

n/a

Example

The following lines of code

<FORM ACTION="setOptionAttributes.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 2"
       CLASS="jsvButtons"
       onClick="performTest(this.form);">
</FORM>

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

produce