mac007 Posted May 5, 2009 Share Posted May 5, 2009 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 /> "; } ?> Link to comment https://forums.phpfreaks.com/topic/156888-make-it-so-double-select-menu-remembers-db-entries-when-updating-record/ Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Take out the selected word in "<option selected value=" Link to comment https://forums.phpfreaks.com/topic/156888-make-it-so-double-select-menu-remembers-db-entries-when-updating-record/#findComment-826486 Share on other sites More sharing options...
mac007 Posted May 5, 2009 Author Share Posted May 5, 2009 sorry.. dont follow you.. remove the whole if statement?? or just the... "selected value='$noticia2[cat_id]'" part?? Link to comment https://forums.phpfreaks.com/topic/156888-make-it-so-double-select-menu-remembers-db-entries-when-updating-record/#findComment-826493 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Take out the selected word in "<option selected value=" Quoting myself. Read carefully. See the selected word in the string I have there? Well, that's somewhere in your script. Find it and remove it. Link to comment https://forums.phpfreaks.com/topic/156888-make-it-so-double-select-menu-remembers-db-entries-when-updating-record/#findComment-826495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.