1

How can I create input type="text" with <select></select> option. In other words I would like to have one field where can I input text, but if I want I could choice option from dropdown list from all values just like with select tag. Is it possible?

2 Answers 2

2

If you want to allow free-text typing with suggestions/pre-defined choices then I would encourage you to look at the HTML5 datalist element (see https://developer.mozilla.org/en-US/docs/HTML/Element/datalist) which is designed for precisely this purpose.

As browser support for this is limited to more recent versions of browsers (and not available at all in Safari, iOS or Android) you'll probably want to Polyfill this with something like JQuery UI autocomplete (see http://jqueryui.com/autocomplete/).

Sign up to request clarification or add additional context in comments.

Comments

1

Not as a built in html control, no. You would need to create one using an input field and another element (such as a div or list) which contains the dropdown values, with javascript gluing the component parts together. There are plenty of tutorials on how to do this dotted around Google.

2 Comments

Just try a search for Javascript combobox, and there's loads more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.