evilboy1151987 Posted May 14, 2010 Share Posted May 14, 2010 i will explain what i exactly want : my site here > http://mwlobby.0fees.net/test/movement.php please visit have 2 files ajax.php & movement.php ajax.php <?php error_reporting (E_ALL); //... $q=$_GET["q"]; //if (empty(trim($q))){ if(trim($q) == ''){ $append = ''; } else{ $append = ' AND car_quantity = '.$q; } $cname=$_GET["cname"]; $con = mysql_connect('******', '*****', '*****'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("fees0_5265972_test2", $con); // SELECT car_number FROM cars WHERE car_quantity = '33' AND customer_name ='kimo' $sql='SELECT car_number FROM cars WHERE customer_name = \''.$cname.'\''.$append; // $sql="SELECT car_number FROM cars WHERE car_quantity = '".$q."' AND customer_name = '".$cname."' //"; $result = mysql_query($sql) or die (mysql_error()); echo "<select name='user'>"; while($row=mysql_fetch_assoc($result)) { echo "<option value=".$row['car_number'].">". $row['car_number']."</option>"; } echo "</select>"; mysql_close($con); ?> ============= movement.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" /> <title>test</title> <script type="text/javascript"> function showUser1(str) { 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; } } var urq = 'ajax.php?q='+str ; xmlhttp.open("GET",urq,true); xmlhttp.send(); } // ================================== function showUser2(stc) { if (stc=="") { 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; } } var urc = 'ajax.php?cname='+stc ; xmlhttp.open("GET",urc,true); xmlhttp.send(); } </script> </head> <body> <form> <p> customer name : <input name="cname" type="text" id="cname" onchange="showUser2(this.value)" /> write kimo</p> <p> car quantity : <input name="q" type="text" id="q" onchange="showUser1(this.value)" /> write 33 or 34</p> <p> </p> </form> <div id="txtHint"></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.