menu list from database problem
Posted: Fri May 11, 2007 10:50 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have two drop down box. Depending on the value selected in 1st drop down menu box, values in the 2nd drop down box should change.I am not able to get values in the 2nd box to change when selected from the 1st box.
But i am getting the values from the database!!!!
Please help
Thanks in advance............Code: Select all
<?PHP include 'opendb.php'; ?>
<html>
<head>
<title>i</title>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='Hotels.php?cat=' + val ;
}
</script>
</head>
<?PHP
@$cat=$HTTP_GET_VARS['cat'];
//$quer2 = mssql_query( "SELECT DISTINCT `Resort`, `ResortID` FROM `Resorts` order by `Resort` ");
$quer2=mssql_query("SELECT DISTINCT Resort,ResortID FROM Resorts order by Resort");
if(isset($cat) && strlen($cat) > 0){
//$quer=mssql_query("SELECT DISTINCT `HotelName` FROM `Hotels` where `ResortID`=$cat order by ``");
$quer=mssql_query("SELECT DISTINCT HotelName FROM Hotels where ResortID=@$cat order by HotelName");
}else{$quer=mssql_query("SELECT DISTINCT HotelName FROM Hotels order by HotelName"); }
echo "<form method=post name=f1 action='dd-check.php'>";
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mssql_fetch_array ($quer2)) {
if($noticia2['ResortID']==@$cat){echo "<option selected value='$noticia2[ResortID]'>$noticia2[Resort]</option>"."<BR>";}
else{echo "<option value='$noticia2[ResortID]'>$noticia2[Resort]</option>";}
}
echo "</select>";
echo "<select name='subcat'><option value=''>Select one</option>";
while($noticia = mssql_fetch_array ($quer)) {
echo "<option value='$noticia[ResortID]'>$noticia[HotelName]</option>";
}
echo "</select>";
echo "<input type=submit value=Submit>";
echo "</form>";
?>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]