Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

I cranked up some code to make a google suggest like functionality using AJAX. Check out the image below:

Google Suggest using AJAX

Although its not perfectly working but you can get an idea how the things work and you can enhance it.

Here is the JavaScript code:

<script language = "javascript"> 

function GetWords(pressevent,myVal) 
{
var charCode = (pressevent.which) ? pressevent.which : (
event.keyCode);

// Check for the enter key
if(charCode!= 13) 
{
    ForumsQuestions.FillList(myVal,GetWords_CallBack)    
    
    
if(charCode == 32) 
    {

     
// Put the value from the from the DIV into the TextBox 
    
var word = document.getElementById("MyDiv").innerHTML; 
    
    document.getElementById("MyTextBox").
value = word.substring(0,word.length - 4); 

    }
}
}
function GetWords_CallBack(response) 
{
    
if(response!=null
    {
    
    document.getElementById("MyDiv").innerHTML = response.
value;  
        
    }
 
}

For the complete article please visit:


</script>

powered by IMHO

 

Posted on Saturday, October 1, 2005 8:21 PM | Back to top


Comments on this post: Google Suggest like feature using AJAX

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net