need help plz
Posted: Thu May 13, 2010 10:24 am
i will explain what i exactly want :
go to my site here > http://mwlobby.0fees.net/test/movement.php
have 2 files ajax.php & movement.php
ajax.php
[size=10pt]=========================
movement.php[/size]
go to my site here > http://mwlobby.0fees.net/test/movement.php
have 2 files ajax.php & movement.php
ajax.php
Code: Select all
<?php
$q=$_GET["q"];
$cname=$_GET["cname"];
$con = mysql_connect('****', '****', '****');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("fees0_5265972_test2", $con);
$sql="SELECT car_number FROM cars WHERE car_quantity = '".$q."' OR 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[/size]
Code: Select all
<!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>