Ib33X Ib33X -4 years ago 242
HTML Question

HTML select form with option to enter custom value

I would like to have input field that users can enter custom text value or choose from drop down,
normal select only offers drop down options.

How can it accept custom value for instance ford?

<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>


Edit:
I used this http://bit.wisestamp.com/uncategorized/htmljquery-editable-combo-2/ solution.
Also I tried jquery ui combobox and it is not working properly

Answer Source

You can't really. You'll have to have both the drop down, and the text box, and have them pick or fill in the form. Without javascript you could create a separate radio button set where they choose dropdown or text input, but this seems messy to me. With some javascript you could toggle disable one or the other depending on which one they choose, for instance, have an 'other' option in the dropdown that triggers the text field.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download