Multiple selected dropdown menu

utkarsh
08:06:13
Hi,
I want multiple select dropdown in a form and populate values in second multiple selected dropdown .I want both dropdowns to be multi selected.
I try this code but not works for me.

<html>
<head>
<SCRIPT language=JavaScript>
function reload(form){
var val=form.id.options[form.id.options.selectedIndex].value;
self.location='dropdown.php?id=' + val;
}
</script>
</head>
<?php
$quer2=mysql_query("SELECT DISTINCT company,id FROM company order by company");
@$id=$_GET['id']; //This line is added to take care if your global variable is off
if(strlen($id) > 0 and !is_numeric($id)){//check if $cat is numeric data or not.
echo "Data Error";
exit;
}
if(isset($id) and strlen($id) > 0){
$quer=mysql_query("SELECT DISTINCT product FROM product where id=$id order by product");
}else{$quer=mysql_query("SELECT DISTINCT product FROM product order by product"); }
echo "<form method=post name=f1 action=''>";
/// Add your form processing page address to action in above line. Example action=dd-check.php////
////////// Starting of first drop downlist /////////
echo "<select name='id' multiple onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['id']==@$id){echo "<option selected value='$noticia2[id]'>$noticia2[company]</option>"."<BR>";}
else{echo "<option value='$noticia2[id]'>$noticia2[company]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////

////////// Starting of second drop downlist /////////
echo "<select name='subcat' multiple><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[product]'>$noticia[product]</option>";
}
echo "</select>";
////////////////// This will end the second drop down list ///////////
// add your other form fields here ////
echo "<input type=submit value=Submit>";
echo "</form>";
smo1234
08-06-2013
Check this Multiple selection of dropdown list. Using this you can modify the script
utkarsh
08-06-2013
Hi,
This is not work for me because i want populating second based on first dropdown
Also both dropdown should be multiple selected.
Please Login to post your reply or start a new topic