The new datalist automatic drop-down prompt text box in html5

Source: Internet
Author: User

In daily page creation, to facilitate user input, you can often enter
When the content is displayed, the autocomplete or autosuggestion function is automatically displayed,
In this way, user input can be accelerated. The current approach is to use ajax, such as DWR.
A lot of information.
In HTML5, The datalist label is added to meet the requirements
For example:

Java code
1. <input type = "text" value = "" list = "fruits"/>
2. <datalist id = "fruits">
3. <option value = "Apple"> </option>
4. <option value = "Orange"> </option>
5. <option value = "Peach"> </option>
6. </datalist>

After such code is run, when you enter the content in the text input box, three types of fruits are displayed in the drop-down list,
We recommend that you enter the following code if you are worried about browser compatibility:
Java code
1.
2. <datalist id = "fruits">
3. Pick your favorite fruit
4. <select name = "fruit_sel">
5. <option value = "Apple"> Apple </option>
6. <option value = "Orange"> Orange </option>
7. <option value = "Peach"> Peach </option>
8. </select>
9. or type one.
10. </datalist>
11. <input type = "text" name = "fruit" value = "" list = "fruits"/>

In this case, the server must capture both fruits and fruit_sel parameters.
Datalist has always been available in firefox versions. This is a compliment, whereas browsers of other versions
For compatibility, refer to this address:
Http://caniuse.com/#feat=datalist



From jackyrong

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.