Forum Moderators: open
xmlhttp.open("GETJSON","lookup.php?sname="+str1+"®="+str,true); <?php
require"config.inc";
if (isset($_POST[reg]) && ($_POST[sname]))
{
$lookup = mysql_query('SELECT * FROM cust WHERE reg = '$_POST[reg]'AND sname LIKE '%$_POST[sname]%'")or die(mysql_error());
if(mysql_num_rows($lookup)==1){
$row = mysql_fetch_array($lookup);
//echo"$row[acc]<br>$row[2]<br>$row[3]<br>$row[4]<br>$row[5]<br>$row[6]";
$test=array(
accno_d => $row[0],
sname_d => $row[4],
reg_d => $row[1],
make_d => $row[2],
model_d => $row[3]
);
$json_d = json_encode($test);
echo"$json_d";
}
else{echo"Not Found";}
}
?> <script>
function showUser(str,str1)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
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 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
if (xmlhttp.responseText==="Not Found")
{document.getElementById("notfound").innerHTML="<font color =red size=1>Details Not Found, please enter manually</font>";}
else
{ var jsonText = xmlhttp.responseText;
var jsonObject= eval('('+jsonText+')');
eval('JSONOBJECT='+jsonText);
var sname=jsonObject.sname_d;
var reg=jsonObject.reg_d;
var make=jsonObject.make_d;
var model=jsonObject.model_d;
var acc=jsonObject.accno_d;
document.getElementById("reg").value=(reg);
document.getElementById("sname").value=(sname);
document.getElementById("make").value=(make);
document.getElementById("model").value=(model);
document.getElementById("add1").value="Account Number "+(acc)+" no address details required";
document.getElementById("reg").readOnly=true;
document.getElementById("sname").readOnly=true;
document.getElementById("make").readOnly=true;
document.getElementById("model").readOnly=true;
document.getElementById("add1").readOnly=true;
document.getElementById("notfound").innerHTML="";
}
}
}
xmlhttp.open("GETJSON","lookup.php?sname="+str1+"®="+str,true);
xmlhttp.send();
}
</script> if (isset($_POST[reg]) && ($_POST[sname]))
{
$lookup = mysql_query('SELECT * FROM cust WHERE reg = '$_POST[reg]'AND sname LIKE '%$_POST[sname]%'")