HTML & lt; select & gt; tag creation single-choice or multiple-choice menu, select multiple

Source: Internet
Author: User

HTML <select> create a single-choice or multiple-choice menu for a tag, select multiple

All mainstream browsers support <select> labels.

You can create one or more select menus for the select element.

The <option> label in <select &> element is used to define available options in the list.

Tip: The select element is a form control that can be used to accept user input in a form.

Attribute

New: New attribute in HTML5.

Attribute Value Description
Autofocus (5) Autofocus Specifies that the focus is automatically obtained in the text area after the page is loaded.
Disabled Disabled Disable the drop-down list.
Form (5) Form_id Specifies one or more forms to which the text area belongs.
Multiple Multiple You can select multiple options.
Name Name Specifies the name of the drop-down list.
Required (5) Required The specified text area is required.
Size Number Specifies the number of visible options in the drop-down list.
This example shows how to create a simple drop-down list box on the HTML page. The drop-down list is an optional list.

 
This example shows how to create a simple drop-down list with pre-selected values. (Note: The pre-selection value refers to the pre-specified preference .)

 

Appendix: Select object

The Select object represents a drop-down list in the HTML form.

In an HTML form, each time a <select> tag appears, a Select object is created.

You can access a Select object by traversing the elements [] array of the form, or using document. getElementById ().

Select object set
Set Description
Options [] Returns an array containing all the options in the drop-down list.
Select Object Attributes
Attribute Description
Disabled Set or return whether to disable the drop-down list.
Form Returns a reference to a form that contains a drop-down list.
Id Sets or returns the id of the drop-down list.
Length Returns the number of options in the drop-down list.
Multiple Set or return whether to select multiple projects.
Name Set or return the name of the drop-down list.
SelectedIndex Set or return the index number of the selected index in the drop-down list.
Size Sets or returns the number of visible rows in the drop-down list.
TabIndex Sets or returns the tab key control order in the drop-down list.
Type Return the Form Type of the drop-down list.
Standard attributes
Attribute Description
ClassName Sets or returns the class attribute of an element.
Dir Set or return the direction of the text.
Lang Set or return the language code of the element.
Title Sets or returns the title attribute of an element.
Select object Method
Method Description
Add () Add an option to the drop-down list.
Blur () Remove the focus from the drop-down list.
Focus () Set focus on the drop-down list.
Remove () Delete An option from the drop-down list.
Select object event handle
Event handle Description
Onchange The event handle that is called when the selection is changed.

Related Article

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.