25.224. Option: an option in a Select elementDOM Level 2 HTML: Node Element HTMLElement HTMLOptionElement25.224.1. ConstructorOption objects can be created with Document.createElement( ), like any other tag. In the DOM Level 0, Option objects can also be dynamically created with the Option( ) constructor, as follows: new Option(String text, String value, boolean defaultSelected, boolean selected) 25.224.2. Arguments
25.224.3. Properties
25.224.4. HTML SyntaxAn Option object is created by an <option> tag within a <select> tag, which is within a <form>. Multiple <option> tags typically appear within the <select> tag: < form ...> < select ...> < option [ value="value" ] // The value returned when the form is submitted [ selected ] > // Specifies whether this option is initially selected plain_text_label // The text to display for this option [ < /option> ] ... < /select> ... /form> 25.224.5. DescriptionThe Option object describes a single option displayed within a Select object. The properties of this object specify whether it is selected by default, whether it is currently selected, the position it has in the options[] array of its containing Select object, the text it displays, and the value it passes to the server if it is selected when the containing form is submitted. Note that although the text displayed by this option is specified outside the <option> tag, it must be plain, unformatted text without any HTML tags so it can be properly displayed in listboxes and drop-down menus that do not support HTML formatting. You can dynamically create new Option objects for display in a Select object with the Option( ) constructor. Once a new Option object is created, it can be appended to the list of options in a Select object with Select.add( ). See Select.options[] for further details. 25.224.6. See AlsoSelect, Select.options[]; Chapter 18 |