el codigo es el siguiente..
Código PHP:
<html>
<head>
<title>Google live search</title>
<style>
#targetDiv {
background-color: #FFEEAA;
width: 30%;
}
</style>
<script languaje="javascript">
var Ajax=false;
if(window.xmlhttpRequest){
Ajax=new XmlhttpRequest();
}
else if (window.ActiveXObject){
Ajax=new ActiveXObject("Microsoft.Xmlhttp2");
}
function getData(datasource){
if(Ajax){
Ajax.open("GET",datasource);
Ajax.onreadystatechange = function(){
if(Ajax.readystate == 4 && Ajax.status == 200){
eval(Ajax.responsetext);
}
}
Ajax.send(null);
}
}
function getSuggest(keyEvent){
keyEvent= (keyEvent) ? keyEvent:window.event;
input =(keyEvent.target) ? keyEvent.target:keyEvent.srcElement;
if(keyEvent.type == "keyup"){
if(input.value){
getData("google.php?qu=" + input.value);
}
else{
var targetDiv = document.getElementById("targetDiv");
targetDiv.innerhtml = "<div> </div>";
}
}
}
function sendRPCDone(unusedVariable, searchTerm, arrayTerm,arrayResults, unusedArray)
{
var data="<table>";
var loopindex;
if(arrayResults.length != 0){
for(var loopindex; loopindex < arrayResults.length; loopindex++){
data+= "<tr> <td>" + "<a href='http://www.google.com/search?q=" +
arrayTerm[loopindex] + "'>" + arrayTerm[loopindex] +
'</a></td><td>' + arrayResults[loopindex] + "</td></tr>";
}
}
data += "</table>";
var targetDiv =document.getElementbyid('targetDiv');
targetDiv.innerhtml = data;
}
</script>
</head>
<body>
<H1>Google live search</H1>
Search for <input id = "textField" type = "text"
name = "textField" onkeyup = "getSuggest(event)">
<div id = "targetDiv"><div></div></div>
</body>
Código PHP:
<?php
$handle = fopen("http://www.google.com/complete/search?hl=en&js=true&qu=" .
$_GET["qu"], "r");
while (!feof($handle)){
$text = fgets($handle);
echo $text;
}
fclose($handle);
?>