Example: http://jsfiddle.net/hY5Wt/
Instead of two arrays, you can have one array of objects. Each object has a label and an index: {label:"First", idx:1} . Autocomplete will use a shortcut to display and select an event, you can access ui.item.idx to get an identifier / index.
$( ".selector" ).autocomplete({ source: [{label:"First", idx:1}, {label:"Second", idx:2}, {label:"Third", idx:3}], select: function(event, ui) { alert(ui.item.idx); } });
You are referring to an autocomplete plugin, but your code looks as if you are using jQuery UI.
Dennis
source share