Ajay Patel
Ajay Patel

Reputation: 5418

jQuery UI Auto suggest select issue

I am using http://jqueryui.com/demos/autocomplete/#default

My data

[{"icd_ID":"2","icd_code":"A00","icd_desc":"Cholera","icd_yn":"N"},
        {"icd_ID":"3","icd_code":"A00.0","icd_desc":"Cholera due to Vibrio cholerae 01, biovar cholere","icd_yn":"Y"},
        {"icd_ID":"4","icd_code":"A00.1","icd_desc":"Cholera due to Vibrio cholerae 01, biovar eltor","icd_yn":"Y"},
        {"icd_ID":"5","icd_code":"A00.9","icd_desc":"Cholera, unspecified","icd_yn":"Y"}
        ]

For "icd_desc" auto suggest value , i want to get "icd_code".

jsfiddle link : http://jsfiddle.net/ajaypatel_aj/PRnc9/

Upvotes: 2

Views: 243

Answers (2)

Shinya Koizumi
Shinya Koizumi

Reputation: 1103

Are you coding this with server side script? The local data is in the response when you request a page right? so just split out 10 items

Upvotes: 1

Andrew Whitaker
Andrew Whitaker

Reputation: 126042

If you are using a local data source, I would transform that data source to conform with what the widget expects:

var source = $.map(availableTags1, function (el) {
    return {
        label: el.icd_desc,
        value: el.icd_code
    };
 });

 $("#tags").autocomplete({
    source: source
 });

Example: http://jsfiddle.net/sXaZX/

Upvotes: 2

Related Questions