开发者

Combobox in jquery [duplicate]

This question already has answers here: Professional jQuery based Combobox control? [closed] (22 answers) 开发者_开发问答 Closed 9 years ago.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜