For example the explanation-the H tml form
As you can see, the HTML page contains a simple HTML form for the input field called "Txt1".
The form of the work is like this:
Event triggers when the user presses and publishes key areas of input
When the event triggers a function requiring showresult () to be executed.
The following form is a <div> so-called "LiveSearch". This is the data Showresult () function returned as a placeholder.
-------------------------------------------------- ------------------------------
The JavaScript
JavaScript code is stored in "Livesearch.js" and related HTML files:
var xmlHttp
function Showresult (str)
{
if (str.length==0)
{
document.getElementById ("LiveSearch").
Innerhtml= "";
document.getElementById ("LiveSearch").
style.border= "0px";
Return
}
Xmlhttp=getxmlhttpobject ()
if (xmlhttp==null)
{
alert (' Browser does not support HTTP Request ')
return
}
var url= "livesearch.php"
url=url+ "q=" +str url=url+
"&sid=" +math.random ()
xmlhttp.onreadystatechange=statechanged
Xmlhttp.open ("Get", Url,true)
xmlhttp.send (null)
}
function statechanged ()
{
if (xmlhttp.readystate==4 | | xmlhttp.readystate== "complete")
{
document.getElementById ("LiveSearch").
Innerhtml=xmlhttp.responsetext;
document.getElementById ("LiveSearch").
Style.border= "1px solid #A5ACB2";
}
function Getxmlhttpobject ()
{
var xmlhttp=null;
Try
{
//Firefox, Opera 8.0+, Safari
xmlhttp=new XMLHttpRequest ();
}
catch (E)
{
//Internet Explorer
try
{
xmlhttp=new activexobject ("msxml2.xmlhttp");
}
catch (E)
{
xmlhttp=new activexobject ("Microsoft.XMLHTTP");
}
return xmlHttp;
}
The back of the PHP program we just return to the data on the line here is not much to write after our site wrote a lot of related articles.