Javascript:如何从键入的表单中找到类似的短语或文本?

Im just practicing with new code and iv got stuck. I want to be able to open a form to post a question on my site, however I was it to show questions that have already been asked which could be similar to what they are asking. So basically like on this site, While im writing this question it shows "Questions that may already have your answer". That is what I want, but cant find how to do it. So I want to be able to write in the form and some code searches questions already in the database to find similar questions. Does anyone know how to do this?



Edit 03/08/2012.

So I think iv done it and this is how I did it, well I think its done anyway. So if anyone is interested in doing this then download the files from the link that Bertrand added, then on the search.php page change the code at the top of the page to this:

include("config.php");
$search_term = filter_var($_GET["s"], FILTER_SANITIZE_STRING);

$array = explode(" ", $search_term);

foreach ($array as $key=>$word) {
$array[$key] = " title LIKE '%".$word."%' ";
}

$q = "SELECT * FROM posts WHERE  " . implode(' OR ', $array) . " LIMIT 0,10";
$r = mysql_query($q);
if(mysql_num_rows($r)==0)//no result found

It seems to be working, I do lose the highlight feature which highlights the words you typed into the search. But I dont mind too much about that. As long as it works :)

I think the answer is an Ajax live seach. Basically you have to get the text the user is typing and run an ajax request that would connect to a page in your server, this page would run the query in your database and return the results, if any, to the request, than you populate the area "Questions that may already have your answer" with them.

Have a look in this tutorial or google for ajax live search with JQuery. http://www.technabled.com/2009/03/how-to-build-animated-ajax-search-with.html