I had a customer drop down if i select customer i should fetch the addaress and tinno

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Praveen040
    New Member
    • Jun 2012
    • 2

    I had a customer drop down if i select customer i should fetch the addaress and tinno

    Please check this code and reply me .....

    Code:
    <script language="JavaScript">
              
    	var listObj=document.getElementById('customer');
    	
    	listObj.selectedIndex=0;
    //	var ind=document.getElementById('list').selectedIndex;
    //alert(ind);
    
    	if(listObj.value!=""){
    		showUser(listObj.value) 	
    	}
    		document.getElementById('customer').style.width="158";
         
    //	document.getElementById('client_list').selectedIndex=0;
        </script>
    
    
    
    var xmlHttp;
    
    var isIE = false;
    
    // on !IE we only have to initialize it once
    if (window.XMLHttpRequest) {
    	xmlHttp = new XMLHttpRequest();
    }
        
    function showUser(str)	
    {
    
    if (window.XMLHttpRequest) {
           // branch for IE/Windows ActiveX version
    	   
       } else if (window.ActiveXObject) {
           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       }
    
       if (xmlHttp==null)
       {
        alert ("Browser does not support HTTP Request");
        return;
      }
    
    
     var url="php/invoicedisply.php"
     
     url=url+"?q="+str
     url=url+"&frm=Client"
     url=url+"&sid="+Math.random()
    	
     xmlHttp.onreadystatechange=processChanged
     xmlHttp.open("GET",url,true)
     xmlHttp.send(null)
     }
    
     function processChanged()
    {
    
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    
    
     xmlDoc=xmlHttp.responseXML;
    
    document.getElementById("address1").value=xmlDoc.getElementsByTagName("address1")[0].childNodes[0].nodeValue;
    document.getElementById("tinno").value=xmlDoc.getElementsByTagName("tinno")[0].childNodes[0].nodeValue;
    }
    }
    
    
    
    
    <?php
        header('Content-Type: text/xml');
        header("Cache-Control: no-cache, must-revalidate");
    
        require("db_connect.php");
      
        $frm=$_GET['frm'];
        if($frm=="Client")
        {
            $q=$_GET["q"];
           
           $sql="SELECT address1,tin_no FROM customermaster WHERE customer_id='".$q."'";
    		
            //echo $sql;
            $result = mysql_query($sql,$link);
            checkError($result);
            echo '<?xml version="1.0" encoding="ISO-8859-1"?><customer>';
           
            while($row = mysql_fetch_array($result))
        {
    	
               echo "<address1>". $row['address1']."</address1>";
    		   
    		     echo "<tinno>". $row['tin_no']."</tinno>";
               
            }
            echo "</customer>";
        }
    
       
    
        mysql_close($link);
        die();
    
        function checkError($result)
        {
            if(!$result){
                echo "<font size=\"4\">MySQL Error : ".mysql_error()."</font>";
                mysql_error();
                die();
            }
        }
    
    ?>
    Last edited by Dormilich; Jun 26 '12, 08:08 AM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    and what exactly is the problem?

    Comment

    Working...