home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Option.selected Property

Name

Option.selected Property---whether the option is selected

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

option.selected

Description

The selected property is a read/write Boolean value that specifies whether a Option object within a Select object is currently selected. You can use this property to test whether a given option is selected. You can also use it to select (by setting it to true) or deselect (by setting it to false) a given option. Note that when you select or deselect an option in this way the Select.onchange() event handler is not invoked.

Usage

To determine the selected options in a Select object, you can loop through the Select.options[] array testing the selected property of each item. When multiple selections are not allowed (i.e., when the MULTIPLE attribute does not appear in the <SELECT> tag), however, it is much easier to simply check use the selectedIndex property of the Select object.


Previous Home Next
Option.index Book Index Option.text

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell