i have tree select boxes. i fill those with data coming from a database (mysql)
i want to change the data of the last two selects regarding the selection of the first.
here is my code. it doesnt work (i used a little bit of javascript)
in head
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='apousies.php?cat=' + val ;
}</script>
in body
//connect with database works fine
@$cat=$_GET['cat'];
@$cat=$HTTP_GET_VARS['cat'];
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT eidikotita, id_eidikotitas FROM eidikotita order by eidikotita");
///////////// End of query for first list box////////////
if(isset($cat) and strlen($cat) > 0){
//it never gets here
$quer=mysql_query("SELECT lastname, firstname, fathersname FROM members where id_eid=$cat order by lastname");
$quer1=mysql_query("SELECT mathima FROM mathimata where id_eid=$cat order by mathima");
}else{$quer=mysql_query("SELECT lastname, firstname, fathersname FROM members order by lastname");
$quer1=mysql_query("SELECT mathima FROM mathimata order by mathima"); }
echo "<form method=post name=f1 action='apousies-ins.php'>";
////////// Starting of first drop downlist /////////
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>lessons</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['id_eidikotitas']==@$cat){echo "<option selected value='$noticia2[id_eidikotitas]'>$noticia2[eidikotita]</option>"."<BR>";}
else{echo "<option value='$noticia2[id_eidikotitas]'>$noticia2[eidikotita]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////
////////// Starting of second drop downlist /////////
echo "<select name='subcat'><option value=''>Êáôáñôéæüìåíïò</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[lastname], $noticia[firstname], $noticia[fathersname]'>$noticia[lastname], $noticia[firstname], $noticia[fathersname] </option>";
}
echo "</select>";
////////////////// This will end the second drop down list ///////////
////third list
echo "<select name='subcat1'><option value=''>ÌÜèçìá</option>";
while($noticia = mysql_fetch_array($quer1)) {
echo "<option value='$noticia[mathima]'>$noticia[mathima] </option>";
}
echo "</select>";
////////////////// This will end the third drop down list ///////////
echo "</form>";
the $cat variable seems empty.
i know i may ask a lot. if it is not possible to check this code could u advice me on how can i solve this problem? (the content of one select box is geting data regarding the selection of a first select box)