I am trying to autocomplete jQuery. I have provided some data, but when I select an item from the drop-down list, it always pops the value into the meta-area elements. I need a shortcut. How to do it? Trying to get it to show the label in the # meta area, not the value.
HTML:
...
area:<input type='text' size='20' id='meta-area' />
<input type='hidden' id='meta_search_ids' value='' />
...
JavaScript:
$(document).ready(function(){
var data =[
{'label':'Core','value':1},
{'label':' Selectors','value':2},
{'label':'Events' ,'value':3}];
$("#meta-area").autocomplete({source:data,
select: function(e, ui) {
$("#meta_search_ids").val(ui.item.value);
$('#meta-area').text('this is what I want');
}
});
});
source
share