2

I've searched online and didn't find even one example of a combo box which could be rendered using plain HTML and Javacript.

Is it possible to have a combobox using standard HTML and Javascript? By combo-box, I mean where input is also possible and a drop-down options are also possible - in a single element. I'm not looking for one select box and in addition another input box.

An example of what I'm looking for is:

https://demos.telerik.com/kendo-ui/combobox/cascadingcombobox

However, I don't want to use any Javascript library like jQuery.

1 Answer 1

1

Seems you are looking for datalist.

datalist is an html5 component. This same feature can be created using input box and ul, li elements

<label for="countries">Choose a Country:</label>
<input list="countryList" id="countries" name="countries" />
<datalist id="countryList">
  <option value="India">
  <option value="France">
  <option value="Isreal">
  <option value="USA">
  </datalist>

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

4 Comments

I agree that he siolution is a datalist - however it should be noted that there is limited browser support for it (eg: Safari does not render it). There is a polyfill that could be used for incompatible browers - just thought it worth mentioning. And also given that its a html5 element - the doctype needs to reflect HTML5.That said - the data-list rocks.
Thanks for the code. I tried it using earlier from another stackoverflow answer. Somehow, it didn't work on IE at my office desktop. However, I see now that it works on Firefox, Chrome and IE.
@gavgrif thanks for your suggestion. Could you please post a working code snippet as brk has done?
RRM - any suggestion i would make has already been posted by @brk - its the right way to do it - then you just have to account for the older browsers etc - search for datalist polyfill and in clude it in the page.

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.