OPTION
in a SELECT
form element.
Server-side function | |
Implemented in | LiveWire 1.0 |
getOptionValue(name, index)
name |
A name specified by the NAME attribute of the SELECT tag
|
index | Zero-based ordinal index of the selected option. |
OPTION
tag. getOptionValue
function is a top-level server-side JavaScript function not associated with any object. It corresponds to the Option.text
property available to client-side JavaScript.<SELECT NAME="what-to-wear" MULTIPLE SIZE=8>You could process the input from this select list in server-side JavaScript as follows:
<OPTION SELECTED>Jeans
<OPTION>Wool Sweater
<OPTION SELECTED>Sweatshirt
<OPTION SELECTED>Socks
<OPTION>Leather Jacket
<OPTION>Boots
<OPTION>Running Shoes
<OPTION>Cape
</SELECT>
<SERVER>If the user kept the default selections, this script would return
var loopIndex = 0
var loopCount = getOptionValueCount("what-to-wear") // 3 by default
while ( loopIndex < loopCount ) {
var optionValue = getOptionValue("what-to-wear",loopIndex)
write("<br>Item #" + loopIndex + ": " + optionValue + "\n")
loopIndex++
}
</SERVER>
Item #1: Jeans
Item #3: Sweatshirt
Item #4: Socks
getOptionValueCount
Last Updated: 10/31/97 16:38:00