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>

Edited by saravanataee
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.