This article will explain the introduction of HTMLselectoption BASICS (options [] array attributes and option Methods) and applications. For more information, see, HTML (select option) for help
I. Basic understanding:
The Code is as follows:
Var e = document. getElementById ("selectId ");
E. options = new Option ("text", "value ");
// Create an option object, that isCreate one or more tagsText // Options is an array that can store multipleTextSuch a label1: options [] attributes of the array:Length attribute --------- length attributeSelectedIndex attribute -------- text index value in the currently selected box, which is automatically allocated by memory (, 2, 3 .....) (The first text value, the second text value, the third text value, and the fourth text value ..........)2: the attribute of a single option (--- obj. options [obj. selecedIndex] is a specifiedTag, which is ---)Text attribute --------- return/specify textValue Attribute ------ returned/specified value,.Index attribute ------- returns the subscript,Selected attribute ------- return/specify whether the object is selected. You can dynamically change the selected item by specifying true or false.DefaultSelected attribute ----- returns whether the object is selected by default. True/false.3: option MethodAdd oneLabel ----- obj. options. add (new ("text", "value ")); DeleteLabel ----- obj. options. remove (obj. selectedIndex) ObtainText of the label ----- obj. options [obj. selectedIndex]. text ModifyTag value ----- obj. options [obj. selectedIndex] = new Option ("new text", "new Value ") Delete allLabel ----- obj. options. length = 0ObtainTag value ----- obj. options [obj. selectedIndex]. valueNote:A: The above is written as obj of this type. options. function () without writing obj. funciton is used to consider compatibility with IE and FF, such as obj. add () is only valid in IE.B: Options in obj. option do not need to be capitalized, and options in new option must be capitalized.II. Application The Code is as follows: