PDA

View Full Version : Autocomplete Jquery Only Matches First Character from the result



round
12-17-2012, 01:42 PM
I am attaching a file of Autocomplete.js
I am having problem like it is matching only first characters of results like following:

I have these 4 results for example
1) How are You?
2) Where are you?
3) Are you there?
4) How is your health?

When I type H then all 4 results should come because all 4 statements are having H inside (There is no case sensitive issue).
But it is giving only 2 results 1st & 4th. Means the first matching characters of statements. But I want all to come. I tried much but could not succeed but I am sure there is any parameter or something like that needs to be changed :)

Is there any hope.

Thanks
Kaushal4848

jscheuer1
12-17-2012, 04:31 PM
You might want to read the documentation:

http://www.devbridge.com/projects/autocomplete/jquery/#how-to-use

The first example site listed on the home page for this script works the way you say you want. It's search box is:


<input type="text" accesskey="4" title="Search for Items Here" name="q" id="q" class="searchbox" value="" />

It's initialization is:


$(function () {

$('#q').each(SetupDefaultSearchText);

var onSelect = function (v, d) {
if (d) {
window.location = d;
} else {
$('#searchform').submit();
}
};

$('#q').autocomplete({ serviceUrl: '/handlers/autocomplete.ashx', width: 390, minChars: 2, onSelect: onSelect });

});

function SetupDefaultSearchText() {
var q = jQuery(this);
var txt = q.attr('title');
if (!txt) { return; }
var onFocus = function () { if (q.val() == txt) { q.val('').removeClass('input-inactive'); } };
var onBlur = function () { if (q.val() == '' || q.val() == txt) { q.val(txt).addClass('input-inactive'); } };
q.focus(onFocus).blur(onBlur);
onBlur();
}

The highlighted parts do not appear to be related to the autocomplete script.

Also that site uses version 1.1, you have version 1.1.5. Probably not important.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

vwphillips
12-17-2012, 04:38 PM
have a look at

http://jqueryui.com/autocomplete/

round
12-18-2012, 06:56 AM
Thank you jscheuer1 & vwphillips for your kind help. I am looking for http://jqueryui.com/autocomplete/ that looks very simple. I used that & resolved the problem.
Thank you both of you once again.

Thanks
Kaushal