Hi can anyone help me find what am i doing wrong. i have an xml request that check data on db and return the result. and base on that result it will clear or highlight a textbox. its working fine using the original function but when i add another xml request the function that i add don't work properly but the first function is working fine
my script
SHOWPLATE WORKING
function showplate(str)
{
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)
{
if (xmlhttp.responseText.trim()=="noplate")
{
$("#platenumber").val('');
document.getElementById('submit').disabled = true;
}
else
{
$("#platenumber").css({'border':'black 1px solid'});
document.getElementById('submit').disabled = false;
}
}
}
xmlhttp.open("GET","../fetch/checkplate.php?q="+str,true);
xmlhttp.send();
};
THIS 1 NOT WORKING
function showdriver(dvr)
{
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)
{
if (xmlhttp.responseText.trim()=="nodriver")
{
$("#driver").val('');
document.getElementById('submit').disabled = true;
}
else
{
$("#driver").css({'border':'black 1px solid'});
document.getElementById('submit').disabled = false;
}
}
}
xmlhttp.open("GET","../fetch/checkdriver.php?d="+dvr,true);
xmlhttp.send();
};
the checkdriver.php
<?php
require ("config.php");
$d= $GET["d"];
$d=trim(preg_replace('/\s+/',' ', $d));
$driver="SELECT Name FROM guestname WHERE Name = '".$d."'";
$sqld = $con->query($driver);
if($sqld->num_rows > 0)
{
echo "yesdriver";
}else{echo "nodriver";}
?>
the checkplate.php
<?php
require ("config.php");
$q= $_GET["q"];
$q=trim(preg_replace('/\s+/',' ', $q));
$q="SELECT plateno FROM platenumber WHERE plateno = '".$q."'";
$sql = $con->query($q);
if($sql->num_rows > 0)
{
echo "yesplate";
}else{echo "noplate";}
?>