Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Form text input suggestions box

I am attempting to modify one of my text input boxes in a form that I have. I would like suggestions to pop up as the user types. Basically, I would like to emulate the "Tags" box that is on the ask question pages here on Stack Overflow, but with different data as the suggestions obviously. How would I go about doing this?

For context, this is for a club at a college, and I am trying to allow members to type in their majors and as they type have a suggestions come up.

like image 503
Ross Larson Avatar asked Jun 23 '11 19:06

Ross Larson


1 Answers

This snippet from Cena Mayo did just what I was looking for:

<input id="color" list="suggestions">
<datalist id="suggestions">
    <option value="Black">
    <option value="Red">
    <option value="Green">
    <option value="Blue">
    <option value="White">
</datalist>

Documentation

like image 84
Nathan Arthur Avatar answered Sep 27 '22 16:09

Nathan Arthur