Posts

Showing posts from November 28, 2009

How to make suggetion box using ajax in php from database onchange event

Image
Hell Friends Here is the example to get data from database using ajax in php (autocomplete) This is the front page viewable to the user. Here is the input box that get input by the user and showData function take the request and send it to the getdata.php file via ajax and send response to the user. index.php <html> <head> <title>autocomplete | Home</title> <script type="text/javascript"> var xmlhttp; function showData(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="getdata.php"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(nodata); } function stateChanged() { if (xmlhttp.readyState == 4) { document.getElementById("txtHint").innerHTML=xmlhttp.resp...