HTMLselectoption basic understanding and use _ HTML/Xhtml _ web page creation

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.