I am really struggling with the jQuery autocomplete plugin. I have a large field in my database with a few words in it, separated by spaces:
postal address name zip code
I can get autocomplete to search for a single word. For instance. if I type "name for name", I get the output:
zip code for the name of the postal address.
However, if I type "last name first name", I get nothing.
Similarly, a zip code is split into two words, for example. AB1 2CD, AB2 2CD. If I type “AB1,” I see “AB1 2CD.” However, if I type "AB1 2CD", I see both results. In Firebug , a new request for receiving after entering a space appears.
I have a selected option, with a separator "". This is the code for how autocomplete is called:
$().ready(function() {
$("#autocomplete input#autotext").autocomplete("clientsearchtest.php", {
width: 400,
multiple: true,
minChars: 2,
cacheLength: 1,
multipleSeparator: " "
});
});
More than just needing “AB1 2CD” to work, I want autocomplete to also show the result “AB1 2CD” when “2cd ab1”, “2cd”, “ab1”, “ab cd” or “ab1 2c” entered. It drives me crazy, any help is much appreciated!
I think what I need to do is somehow send each spaced string as another variable in a PHP script. therefore, currently the entire string is sent as $q. I really need to send $q1, $q2each of which is defined by the presence of a space character. So my SQL select query can have whereearchearch LIKE '% $ q%' AND '% $ q2'.