I am using a auto complete to my textbox. I want the ID retrieved to my json should be store in hidden textbox id=”special” saved as comma separated. Suppose what so ever value I select in autosuggestion its id should get store in hidden textbox separated as comma.
How can I minimize this piece of code. I am new with jquery.
$(".artist").focus().autocomplete( '<?php echo HTTP_PATH . '/artists/getArtistList'; ?>', {
multiple: true,
mustMatch: true,
matchContains: true,
scroll: true,
minChars: 0,
autoFill: true,
dataType: "json",
parse: function(data) {
return $.map(data, function(item) {
return { data: item, value: item.name, result: item.name};
});
},
formatItem: function(item) {
return item.name;
},
formatResult: function(item) {
return item.id;
},
formatMatch: function(item) {
return item.name;
}
});
Are you using jQuery UI or are you using a different plugin? If you are using jQuery UI then you can refer to http://jqueryui.com/autocomplete/#remote-jsonp