4

I've searched the Internet for quite a long time, but I can't find a combobox that fits my needs. Can anyone help me? Thanks in advance!

What I need is a dropdownlist that has an editable box, which acts exactly as the combobox in a Windows desktop application. I have a list of values for the user, but I also want them to be able to type in a value if the list doesn't contain the value they need. I'm using ASP.NET MVC, so I want to make sure the control can be bound by the default model binder. Thanks!

Best regards

Pieniadz
  • 653
  • 3
  • 9
  • 22
Roy
  • 2,313
  • 6
  • 37
  • 46
  • See http://stackoverflow.com/questions/195270/professional-jquery-based-combobox-control – Bipul Apr 17 '10 at 03:55

1 Answers1

5

The solutions on Professional jQuery based Combobox control? all focus on using the input as a means to filtering and autocompleting to an existing select value.

If you're looking for the traditional combo box, which is simply "Type something or select from these pre-defined values" (no we won't hide the ones that don't match while you're typing), all you may need to do is

<select id="combo4" style="width: 200px;"
            onchange="$('input#text4').val($(this).val());">
    <option>option 1</option>
    <option>option 2</option>
    <option>option 3</option>
</select>
<input id="text4"
       style="margin-left: -203px; width: 180px; height: 1.2em; border: 0;" />

See http://bit.wisestamp.com/uncategorized/htmljquery-editable-combo-2/

Should be easy to wrap this into a plugin that converts an existing select tag, though I haven't seen that done yet.

Community
  • 1
  • 1
Danny W. Adair
  • 12,498
  • 4
  • 43
  • 49