Jump to content

Triple drop down issue!


saravanataee

Recommended Posts

Hi there,

 

I am having the following triple drop down page and the code does works very well.

 

But one small change i need to make.. the following code does shows three drop downs from which i can perform the action.

 

Instead i want the three drop down's to be displayed inside a table as three different coloums.

 

when i tried with <td>.<tr> it thrown me error.

 

Any suggestion on how to put them in place inside a table but without changing functionality.

 

 

<?php



require "config.php";
?>


<!doctype html public "-//w3c//dtd html 3.2//en">


<html>


<head>
<title>Demo of Three Multiple drop down list box</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='index.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='index.php?cat=' + val + '&cat3=' + val2 ;
}


</script>
</head>


<body>
<table border="1">


<?php



///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT itemname,item_id FROM item order by itemname");
///////////// End of query for first list box////////////


/////// for second drop down list we will check if category is selected else we will display all the subcategory/////
$cat=$_GET['cat']; // This line is added to take care if your global variable is off
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing where item_id=$cat order by packingname");
}else{$quer=mysql_query("SELECT DISTINCT packingname,packing_id FROM packing order by packingname"); }
////////// end of query for second subcategory drop down list box ///////////////////////////



/////// for Third drop down list we will check if sub category is selected else we will display all the subcategory3/////
$cat3=$_GET['cat3']; // This line is added to take care if your global variable is off
if(isset($cat3) and strlen($cat3) > 0){
$quer3=mysql_query("SELECT DISTINCT sizename FROM size where packing_id=$cat3 order by sizename");
}else{$quer3=mysql_query("SELECT DISTINCT sizename FROM size order by sizename"); }
////////// end of query for third subcategory drop down list box ///////////////////////////



echo "<form method=post name=f1 action='dd3ck.php'>";
////////// Starting of first drop downlist /////////
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['item_id']==@$cat){echo "<option selected value='$noticia2[item_id]'>$noticia2[itemname]</option>"."<BR>";}
else{echo "<option value='$noticia2[item_id]'>$noticia2[itemname]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////


////////// Starting of second drop downlist /////////
echo "<select name='subcat' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
if($noticia['packing_id']==@$cat3){echo "<option selected value='$noticia[packing_id]'>$noticia[packingname]</option>"."<BR>";}
else{echo "<option value='$noticia[packing_id]'>$noticia[packingname]</option>";}
}
echo "</select>";
////////////////// This will end the second drop down list ///////////



////////// Starting of third drop downlist /////////
echo "<select name='subcat3' ><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer3)) {
echo "<option value='$noticia[sizename]'>$noticia[sizename]</option>";


//echo "<input type='text' name='' value='$noticia[sizename]'/>";
}
echo "</select>";
////////////////// This will end the third drop down list ///////////


?>
</table>


</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/272645-triple-drop-down-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.