HTML <select> tags create a single or multi-select menu

Source: Internet
Author: User

All major browsers support <select> tags.

The Select element creates a single-or multiple-selection menu.

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

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

Property

The new property in the NEW:HTML5.

Properties value Description
Autofocus (5) Autofocus Specifies that the text area automatically receives focus after the page is loaded.
Disabled Disabled Specifies that the drop-down list is disabled.
Form (5) form_id Specifies one or more forms to which the text area belongs.
Multiple Multiple Specifies that multiple options can be selected.
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 in an HTML page. The drop-down list box is an optional list.
 select  name= " cars  "  ><option value=< Span style= "color: #800000;" > " volvo  "  >volvo</option ><option value=  " >saab</option><option value="  fiat   >fiat</option><option value="  audi   " >Audi</option> </select  ></form></body>
This example shows how to create a simple drop-down list with preselected values. (Translator Note: Preselected values refer to pre-specified preferences.) )
SelectName="Cars"><option value="Volvo">volvo</option><option value="Saab">saab</option><option value="Fiat"Selected="selected">fiat</option><option value="Audi">audi</option></Select></form></body>

Attached: Select Object

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

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

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

Select Object Collection
Collection Description
Options[] Returns an array that contains all the options in the drop-down list.
Select Object Properties
Properties Description
Disabled Sets or returns whether the drop-down list should be disabled.
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 Sets or returns whether multiple items are selected.
Name Sets or returns the name of the drop-down list.
SelectedIndex Sets or returns the index number of the selected item 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 control order for the drop-down list.
Type Returns the form type of the drop-down list.
Standard properties
Properties Description
ClassName Sets or returns the Class property of an element.
Dir Sets or returns the direction of the text.
Lang Sets or returns the language code of the element.
Title Sets or returns the title property of an element.
Select Object method
Method Description
Add () Add an option to the drop-down list.
Blur () Move the focus away from the drop-down list.
Focus () Set the focus on the drop-down list.
Remove () Removes an option from the drop-down list.
Select Object Event Handle Handle
EventDescription
OnChange The event handle that is invoked when the selection is changed.

HTML <select> Tags create a single or multi-select menu

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.