Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<input type="text" id="selector">

JavaScript
jQuery(function(){

$('#selector').autocomplete("URL");

});

This function is working for me.
But it should fire a ajax call when changes happened in auto complete.

JavaScript
$('#selector').change(function(){
   alert($('#selector').val());
});


The above code is not working properly. Suppose if i enter value as "Cycle" in auto complete,
the change event passing only a first character of "Cycle".

Please can anyone help to get full value when change happened in auto complete box.
Posted
Updated 19-Dec-13 21:13pm
v3
Comments
What it alerts by below line?

alert($('#selector').val());
srkrishnan0509 20-Dec-13 3:12am    
<input type="text" id="selector">

After filling this input, i should fire chnage event.

tat alerts will print the value of tat input box.
Check my answer. Your code is working perfectly.
srkrishnan0509 20-Dec-13 5:01am    
I know it will work man.. when i am selecting auto complete option its just alerting first character of the string.
I am not sure what you are talking. But take a look at the below demo link.

Autocomplete Demo[^].

I entered cycle, it shows me "Cycle", then I select that and press tab or move mouse out of the TextBox. So, it alerts me "Cycle".

Then what is the problem?

But the change event is working as expected with your code.

See the Demo - [Demo] jQuery TextBox onChange Event[^].


[Edit]
Quote:
Is there any change event for auto complete.
Yes there is.
Now check my Demo. Autocomplete Change[^].
 
Share this answer
 
v2
<input type="text" id="selector">


C#
var availableTags = [
    "ActionScript",
    "AppleScript",
    "Asp",
    "BASIC",
    "C",
    "C++",
    "Clojure",
    "COBOL",
    "ColdFusion",
    "Cycle",
    "Erlang",
    "Fortran",
    "Groovy",
    "Haskell",
    "Java",
    "JavaScript",
    "Lisp",
    "Perl",
    "PHP",
    "Python",
    "Ruby",
    "Scala",
    "Scheme"];
$("#selector").autocomplete({
    source: availableTags,
    change: autoCompleteChanged
});

function autoCompleteChanged(event, ui) {
    alert($('#selector').val());
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900