Search code examples
htmlcomboboxhtml-select

How can I create an editable dropdownlist in HTML?


I'd like to create a text field with a dropdown list that lets the user choose some predefined values. The user should also be able to type a new value or select a predefined one from a dropdown list. I know that I can use two widgets for that but in my app it would be more ergonomnic if it was unified in a one widget.

Is there a standard widget or do I have to use a third party javascript?

How about browser portability?


Solution

  • The best way to do this is probably to use a third party library.

    There's an implementation of what you're looking for in jQuery UI jQuery UI and in dojo dojo. jQuery is more popular, but dojo allows you to declaratively define widgets in HTML, which sounds more like what you're looking for.

    Which one you use will depend on your style, but both are developed for cross browser work, and both will be updated more often than copy and paste code.