开发者

AutoSuggest from a array

开发者 https://www.devze.com 2023-01-18 04:01 出处:网络
I have a php script which generates JS array in this form new Array( new Array(\"Maine\", 1), new Array(\"Maryland\", 2),

I have a php script which generates JS array in this form

new Array(

    new Array("Maine", 1), 

    new Array("Maryland", 2), 

    new Array("Massachusetts", 3), 

    new Array("Michigan", 4), 

    new Array("Minnesota", 5), 

    new Array("Mississippi", 6), 

    new Array("Missouri", 7),开发者_JS百科 

    new Array("Montana", 8)

);

can some one please suggest , how to implement a Auto Suggestion for the search form ?

Thanks


Use jQuery UI autocomplete:

Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:

  • an Array with local data
  • a String, specifying a URL
  • a Callback

The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.

0

精彩评论

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