Autocomplete plugin, how to use formatMatch option
Hi everyone
I'm working on a company name autocomplete on our intranet DB
But as the user types the company, I'd really like to also show the
town/country but not have them matched
From the brief description here...
http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions
it looks like I need the formatMatch option but I can't work out how
to use it.
I'm basing my solution on the Single Birds remote example here
http://view.jquery.com/trunk/plugins/autocomplete/demo/
I output my data from the DB in the format:
company_name|company_id
company_name|company_id
etc
I can easily change it to output as: company_name(delimeter)
town_country|company_id
But I don't know how to stop the bit after the delimeter from
matching.
Here's my jquery code so far:
$(document).ready(function() {
$("#link_company_search").autocomplete("company_autocomplete.php", {
cacheLength: 10, matchSubset: true, max: 30, minChars: 3, mustMatch:
true, selectFirst: false, width: 300
});
$("#link_company_search").result(function(event, data, formatted) {
if (data)
$("#link_id").val(data[1]);
});
});
That second .result section gets the bit after the | pipe character
and sets it to a hidden input link_id as that's what I need on the
next page of my script.
Can anyone help me out with formatMatch?
Cheers, B