I need my application to auto-complete on a company name, but also fill in a hidden form field with the ID of that company selected.
I believe it's possible to return pair values, with the pipe separator, such as........
Microsoft|10
Orac开发者_开发知识库le|20
Sybase|30
And indeed this seems to work, but I don't know how to access the 2nd argument.
Everything should be returned within your select function. Your select function should be similar to this:
function autoCompleteSelected(event, item, formatted)
{
item[0]; // Should be Microsoft
item[1]; // Should be 10;
}
Then to specify the select function:
$("#autoCompleteField").autocomplete(url).result("autoCompleteSelected");
精彩评论