Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually type in a value in a "Select" / Drop-down HTML list?

In a Windows Forms application, a drop-down selector list also gives the user the option of typing an alternate value into that same field (assuming the developer has left this option enabled on the control.)

How does one accomplish this in HTML? It appears as if it is only possible to select values from the list.

If it's not possible to do this with straight HTML, is there a way to do this with Javascript?

like image 466
Pretzel Avatar asked Dec 13 '10 15:12

Pretzel


People also ask

How do you display a selected value in a drop-down list in HTML?

To get the value of a select or dropdown in HTML using pure JavaScript, first we get the select tag, in this case by id, and then we get the selected value through the selectedIndex property. The value "en" will be printed on the console (Ctrl + Shift + J to open the console).

How do I style a select dropdown?

There are many ways to design a <select> dropdown menu using CSS. The Dropdown Menu is mainly used to select an element from the list of elements. Each menu option can be defined by an <option> element that can nested inside the <select> element.


1 Answers

It can be done now with HTML5

See this post here HTML select form with option to enter custom value

<input type="text" list="cars" /> <datalist id="cars">   <option>Volvo</option>   <option>Saab</option>   <option>Mercedes</option>   <option>Audi</option> </datalist> 
like image 91
Pottsy Avatar answered Oct 14 '22 14:10

Pottsy