25.253. Select: a graphical selection listDOM Level 2 HTML: Node Element HTMLElement Select25.253.1. Properties
In addition to the properties above, Select objects also mirror HTML attributes with the following properties:
25.253.2. Methods
25.253.3. Event Handlers
25.253.4. HTML SyntaxA Select element is created with a standard HTML <select> tag. Options to appear within the Select element are created with the <option> tag:
25.253.5. DescriptionThe Select element represents an HTML <select> tag, which displays a graphical list of choices to the user. If the multiple attribute is present in the HTML definition of the element, the user may select any number of options from the list. If that attribute is not present, the user may select only one option, and options have a radio-button behaviorselecting one deselects whichever was previously selected. The options in a Select element may be displayed in two distinct ways. If the size attribute has a value greater than 1, or if the multiple attribute is present, they are displayed in a list box that is size lines high in the browser window. If size is smaller than the number of options, the listbox includes a scrollbar so all the options are accessible. On the other hand, if size is specified as 1 and multiple is not specified, the currently selected option is displayed on a single line, and the list of other options is made available through a drop-down menu. The first presentation style displays the options clearly but requires more space in the browser window. The second style requires minimal space but does not display alternative options as explicitly. The options[] property of the Select element is the most interesting. This is the array of Option objects that describe the choices presented by the Select element. The length property specifies the length of this array (as does options.length). See Option for details. For a Select element without the multiple attribute specified, you can determine which option is selected with the selectedIndex property. When multiple selections are allowed, however, this property tells you the index of only the first selected option. To determine the full set of selected options, you must iterate through the options[] array and check the selected property of each Option object. The options displayed by the Select element may be dynamically modified. Add a new option with the add( ) method and the Option( ) constructor; remove an option with the remove( ) method. Changes are also possible by direct manipulation of the options array. 25.253.6. See AlsoForm, Option, Select.options[]; Chapter 18 |
Wednesday, December 16, 2009
Section 25.253. Select: a graphical selection list
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment