Hello, all:
Hoping somebody can help me with this... I have this "double-dynamic-select-menus" borrowed script which uses a bit of Javascript to switch menu-options based on selection made on main related menu (main category and subcategory option-menus). It works great when I am just simply adding a new item; but when I need to UPDATE an item, I can't seem to make it work so it remembers the item's database "option" settings... I tried different things, inserting if-else statements within the select-menu codes, but no luck...
appreciate any help!!
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='?productID=<?php echo $row_workModifyRS['ProductID']; ?>&cat=' + val ;
}
</script>
<?
@$cat=$_GET['cat'];
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category");
/////// for second drop down list we will check if category is selected/////
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
}
////////// 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['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}
else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";}
}
echo "</select>
";
////////////////// end of the first drop down list ///////////
////////// Starting of second drop downlist /////////
if (mysql_num_rows($quer) > 0) {
echo "<span class='style5'>Subcategory:</span>
<select name='subcat'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
}
echo "</select><br />
<br />
";
}
?>