Web Analytics Made Easy -
StatCounter Select Form Option - CodingForum

Announcement

Collapse
No announcement yet.

Select Form Option

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select Form Option

    I see on some sites there is a drop down menu "SELECT" but these websites allow you to type in the field or select the drop down.

    How do you do this?

  • #2
    That's called a combobox - it was added to HTML just recently. To do it you don't use a <select> - you use an <input> and attach the <option>s in a <datalist>

    For example the following code is for a combobox where you can select an Australian state from the dropdown or simply type in the state if it isn't in Australia. The list attribute in the input field needs to match the id in the datalist to attach them together.

    Code:
    <input type="text" list="state">
    <datalist id="state">
    <option>ACT</option>
    <option>NSW</option>
    <option>NT</option>
    <option>QLD</option>
    <option>SA</option>
    <option>TAS</option>
    <option>VIC</option>
    <option>WA</option>
    </datalist>
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

    Comment

    Working...
    X