Click here to Skip to main content
14,832,080 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends, here my question :

JavaScript
<script>
jQuery(function() {
    $("#itemname").autocomplete("AutoComp?mode=itemName");
});
</script>

Auto complete working fine.

But, I am using this value to another ajax function.
If I use this
JavaScript
$(document).ready(function(){ 
   $("#itemname").focusout(function(){
                            
      var itemName=$(this).val();
      alert(itemName);
   });
});


Alert showing only text which are entered by me.
But I want full text value generated by an auto complete.

Thank You.
Posted
Updated 22-Dec-13 8:42am
v3
Comments
ZurdoDev 20-Dec-13 13:08pm
   
View the source and see what property has what you are looking for.

1 solution

Alright Friend,

I may not possibly be able to give you any code at the moment 'cause I have to do few tests to do so but I can give you idea.

See this is obvious, your code actually picks the value of the textbox which the user has entered. So, you have to do something like this.

1. Everytime the autcomplete generates the suggestion store it in a global variable which is available to at least the functions defined inside $(document).ready(function(){});

2. When you have stored the variable, now when the focusout event is fired simply use the value stored in the variable rather than the value from the textbox.

Now to implement the first part I would suggest you to look Here

Hope it is of some help. Do rate it :)

With Regards
Tushar Srivastava
   

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