cookspyder Posted July 23, 2007 Share Posted July 23, 2007 I have a form that pulls mysql data to build a drop down menu, and then to obtain the page reload for a series of check boxes. When I sumbit the page I do not carry over the first value selected in the drop down. Instead I get the number associated with that particular field. just as an example: localhost/form.php?=4 4 is the value asociated with dog in the drop down. the name of the selected value is called pet. ie cat=1 bird=2 reptile=3 dog=4 on reload to get the associated breeds it needs that number in the url associated to the animal. then on submit I can not get the animal instead of number... any ideas? can I submit both the num and animal type? here is the drop down and check box actual code. ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); ///////////// End of query for first list box//////////// echo "<form method=post name=f1 action='dd-check.php'>"; ////////// Starting of first drop downlist ///////// echo "Please select the monitored Service:<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>"; ////////////////// This will end the first drop down list /////////// if(isset($cat) and strlen($cat)>0){ $quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory"); }else{$quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory order by subcategory"); } ////////// end of query for second subcategory drop down list box /////////////////////////// echo "<p>"; ////////// Starting of checkbox///////// echo "Please Select the Application or Server effected by Maintenance:</br>"; //echo "<input type='checkbox' value=''>Entire Service</input></br>"; while($noticia = mysql_fetch_array($quer)) { if($cat>0){ echo "<input type='checkbox' name='subcat[]' value='$noticia[subcategory]'>$noticia[subcategory]</input></br>"; //echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>"; }} echo "</input>"; Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 23, 2007 Share Posted July 23, 2007 Well...you are telling it to pass on the number instead of the "category". Change this line: value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";} To: value='$noticia2[category]'>$noticia2[category]</option>"."<BR>";} Quote Link to comment Share on other sites More sharing options...
cookspyder Posted July 23, 2007 Author Share Posted July 23, 2007 Thanks, I knew it was something simple just looking at the code too long! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.