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";}

?>

Recommended Answers

All 3 Replies

Hmm... Line 9 in driver... Shouldn't it be $d instead of $driver?

hi line 9 is fine the query is working when i insert a value directly to the query. its seems that the js is not passing the data to the php file. but the thing is the showdriver function is just a copy paste of the showplate function.doest xml request can only be pass once? but then they are different function im total lost.

it must be $d= $_GET["d"];
not $d= $GET["d"];

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.