Option.selected

JavaScript 1.2+ Nav4+ Syntax

							option.selected

Description

The selected property of the Option object specifies the current selected option of the select list.

Example

Listing 7.410 shows an example of how the selected property is used. The check function checks to see what the selected property is.

Listing 7.410 Example of the selected Property
 <html> <head> <title> Example of the selected property of the option object</title> </head> <body> <script language="JavaScript"> <!--Hide // function checks the forms to see what the selected property is function check(myForm){ for (var i = 0; i < document.form1.myList.length; i++) { if (document.form1.myList.options[i].selected == true) { alert("The selected value is: " + document.form1.myList.options[i].value); ...

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.