Hey Guys,
I need your help again. I have a php page where I am trying to get the user's selection via a multiple dropdown list.
<?php
include "include/dbc.php";
include "include/header.inc";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Select Activities</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='act.php?cat=' + val ;
}
function reload3(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
var val2=form.subcat.options[form.subcat.options.selectedIndex].value;
self.location='act.php?cat=' + val + '&subcat=' + val2 ;
}
</script>
</head>
<body>
<?
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT Type FROM exercise order by Type");
///////////// End of query for first list box////////////
/////// for second drop down list we will check if sub category is selected else we will display all the subcategory3/////
$name=$_GET['Name']; // This line is added to take care if your global variable is off
if(isset($name) and strlen($name) > 0){
$quer3=mysql_query("SELECT DISTINCT Name FROM exercise where No=$name order by Name");
}else{$quer3=mysql_query("SELECT DISTINCT Name FROM exercise order by Name"); }
////////// end of query for third subcategory drop down list box ///////////////////////////
echo "<form method=post name=f1 action='actck.php'>";
////////// Starting of first drop downlist /////////
echo "<select size ='10' name='cat' \"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['No']==@$type){echo "<option selected value='$noticia2[Type]'>$noticia2[Type]</option>"."<BR>";}
else{echo "<option value='$noticia2[Type]'>$noticia2[Type]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////
////////// Starting of third drop downlist /////////
echo "<select size ='10' name='subcat' multiple><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer3)) {
echo "<option value='$noticia[Name]'>$noticia[Name]</option>";
}
echo "</select>";
////////////////// This will end the third drop down list ///////////
echo "<input type=submit value='Submit the form data'></form>";
?>
</html>
<?php include "include/footer.inc"; ?>
The problem I'm having is that the first dropdown list keeps reloading and the second dropdown list is never populated based on the user's selection in the first dropdown box. The 2nd box just site there. Based on the code, what suggestions do you all have?