Good Javascript Combo Box replacement for combo boxes with tons of elements?

最后都变了- 提交于 2019-12-12 10:54:36

问题


I have a page where my combo box has hundreds of elements which makes it very hard to pick the one item I want. Is there a good Javascript replacement that would do better than

<select id="field-component" name="field_component"> 
                  <option selected="selected">1</option><option>2</option>...
</select>

Is there something with "Intellisense"-like auto-complete?


回答1:



You have dhtmlCombo, using ajax to retrieve data when you are filling the input field.

dhtmlxCombo is a cross-browser JavaScript combobox with autocomplete feature.

It extends basic selectbox functionality to meet the requirements of the most up-to-date web applications.

dhtmlxCombo can be converted from existing HTML SELECT or populated with JavaScript. Supporting AJAX, it can also get list values from the server datasource dynamically.




回答2:


In HTML 5 there's standard combo box.

Currently only Opera supports it, but if you happen to be time traveller or writing Opera-only application, it's a nice solution :)

<input type=text list=listid>
<datalist id=listid>
  <select><option>1<option>2</select>
</datalist>



回答3:


Check the jQuery Autocomplete plugin, it's easy to use, you only have to generate a JSON response server side.

See this demos.




回答4:


The autocompleter using Prototype and Scriptaculous works well in this situation.




回答5:


Just a note: If the select box is current focused, you can type on your keyboard and it will take you to the selection beginning with that text, so typing "k-e-n" into a US State dropdown would auto-select the "Kentucky" option.




回答6:


You can try this combobox realization http://www.zoonman.com/projects/combobox/

  • Pure JavaScript. Editable. Supports IE6.
  • Nonstandard HTML layout.



回答7:


I think Twitter's free typeahead.js library is the best autocomplete library available today. Check it out at http://twitter.github.io/typeahead.js/



来源:https://stackoverflow.com/questions/262150/good-javascript-combo-box-replacement-for-combo-boxes-with-tons-of-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!