hi,
i have two drop down list.
First one is populated from database and its working fine.
Second one will also be populated from database but as per the value selected from the first drop-down list.
<head>
<script type="text/javascript">
function xyz_list()
{
// xyz_list is the id of ;;my first drop-down list
var xyz_list=document.getElementById("mob_list");
brand=xyz_list.options[mob_list.selectedIndex].text;
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 &&amp; xmlhttp.status==200)
{
document.getElementById("xyz").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","XYZ.php?brand=" + brand,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select id="xyz" onfocus="xyz_list()">
<OPTION VALUE=All>All
<?php echo $options?>
</SELECT>
</form>
</body>
Below is the xyz.php script
<?php
$brand=$_GET['brand'];
//alert($brand);
//below is just inserting a blank value in drop list
$options_mobile.="<OPTION VALUE=abc>".$brand.'</option>';
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mobile1", $con);
$sql="SELECT xyz FROM abc where pqr= '$brand'";
$result = mysql_query($sql);
$options.="<OPTION VALUE=\"$result\">".$result.'</option>';
while($row = mysql_fetch_array($result))
{
// $xyz=$row["xyz"];
$xyz=$row["xyz"];
$options.="<OPTION VALUE=\"$xyz\">".$xyz.'</option>';
}
mysql_close($con);
?>
I am new to both of the languages, but i know wat my code wants to do. i googled a lot to find the error, But i cant figure out where i am wrong.
Any help will be highly appreciated.