HTML5 has a built-in combo box. You create a text input
and a datalist
. Then you add a list
attribute to the input
, with a value of the id
of the datalist
.
Update: As of March 2019 all major browsers (now including Safari 12.1 and iOS Safari 12.3) support datalist
to the level needed for this functionality. See caniuse for detailed browser support.
It looks like this:
<input type="text" list="cars" />
<datalist id="cars">
<option>Volvo</option>
<option>Saab</option>
<option>Mercedes</option>
<option>Audi</option>
</datalist>