views:

62

answers:

1

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
Oracle|20
Sybase|30

And indeed this seems to work, but I don't know how to access the 2nd argument.

+1  A: 

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");
GenericTypeTea