iRobot.js
This file is the Ajax function call that allows the event to call the php server side function, the response will echo secret data onto your form (to be used in the form submission).
function iRobot(str, name )
{
if (str.length==0)
{
document.getElementById(name).innerHTML="";
document.getElementById(name).style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
if (xmlhttp.status==200)
{
document.getElementById(name).innerHTML=xmlhttp.responseText;
document.getElementById(name).style.border="0px";
}
}
else
document.getElementById(name).innerHTML="< img src=`/images/loading9.gif` alt=`Please wait....` >" ;
}
xmlhttp.open("GET","/iRobot.php?q="+str,true);
xmlhttp.send();
}