I am using the jQueryUI autocomplete for a textbox. I want the textbox to be filled in a way that as soon as the textbox is autocompleted, a variable should be set to a particular value associated with that particular autocomplete option.
Source for autocomplete:
var availableTags = ["Air University","Alabama A&M University",
"Alabama State University","Athens State University",...];
//list very long, 2000+
I think the source should be converted as a JSON object such as
[{ "id":"1", "name":"Air university";}....];
And then when Air university is selected, a variable should be set to the value in 'id'.
Code:
$( "#tags" ).autocomplete({
source: function(request, response) {
var results = $.ui.autocomplete.filter(availableTags, request.term);
response(results.slice(0, 10));
},
minLength:5
});
How can this be done?