Select.options.value

JavaScript1.0+, JScript1.0+ Nav2+, IE3+, Opera3+ Syntax

							select.options.value

Description

The value property of the options array of the Select object returns the value of the option that is selected in that instance of a select box.

Example

Listing 7.476 has a single select box. When the user makes a selection, the onChange event handler is used to pop up an alert box that displays the value of the selected option in this select box.

Listing 7.476 Accessing the value Property of the options Array of a Select Object
 <form name="myForm"> <select name="mySelect" onChange='alert(mySelect.options[selectedIndex].value)'> <option value=HOCK>Hockey</option> <option value=RUG name=TEST>Rugby</option> <option value=GOLF>Golf</option> ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.