Jquery 自定义选择/组合框
我正在使用 jQuery;我有一个选择框,其选项是从 json 对象填充的。但由于数据库可能不完整,我想为用户提供输入自定义值的能力。我一直在寻找的大多数组合框解决方案都以某种方式出现故障。在这种情况下有哪些替代解决方案?
I am using jQuery; I have a select box the options of which are populated from a json object. But because the database is potentially incomplete, I would like to offer the user the ablity to enter a custom value. Most combobox solutions, I have been looking at are malfunctioning one way or the other. What are alternative solutions in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 jQuery 可编辑组合框插件 来实现此目的。
You can use the jQuery Editable Combobox plugin for that.
也许是一个自动完成框?用户可以开始输入并显示您的选项,但也可以输入不同的值。例如:
QuickSelect 插件可以将您的
Maybe an auto-complete box? Where the user can start typing and your options are presented, but a different value can be typed in as well. Like:
The QuickSelect plug-in can change your
<select>
box into one of these.http://github.com/dcparker/jquery_plugins/tree/master/quickselect
Professional jQuery based Combobox control? 上的解决方案都侧重于使用输入作为手段过滤并自动完成现有的选择值。
我看到“jQuery 可编辑组合框”的主要问题是它仍然是一个选择列表,而且您可以开始输入新内容这一点并不明显。
如果您正在寻找传统的组合框,即“键入某些内容或从这些预定义值中进行选择”(不,我们不会隐藏您键入时不匹配的值),您可以需要做的是
查看
http://bit.wisestamp.com/uncategorized/htmljquery-editable-combo -2/
应该很容易将其包装到转换现有选择标签的插件中,尽管我还没有看到这样做。
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.
The main problem I see with "jQuery Editable Combobox" is that it remains a select list, and it is not obvious at all that you can just start typing something new.
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
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.