javascript - Add object array to jquery-ui autocomplete -


i'm using jquery-ui plugin, i'm trying accomplish use array of pair values (key , label value) source autocomplete text input. array looks like:

var valuesarray = [{     label: 'name_1',     key: 1 }, {     label: 'name_2',     key: 2 }, {     label: 'name_3',     key: 3 }, {     label: 'name_4',     key: 4 }]; 

i need label attribute appear in text input while getting key attribute when retrieving input text element value.

thanks in advance

i think understand, need.

    $("#someid").autocomplete({             source: function(request, response) {         var data = [{         label: 'name_1',         key: 1     }, {         label: 'name_2',         key: 2     }, {         label: 'name_3',         key: 3     }, {         label: 'name_4',         key: 4     }];          response(data);     },     select: function( event, ui ) {         $( "#someid" ).val( ui.item.key);          alert(ui.item.key);         return false;     } }); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -