shadiadiph Posted December 27, 2008 Share Posted December 27, 2008 mm another toughie I can't get my head round. I have a category and sub category selection field which are values called from a database. here is the script which works <? $quer2=mysql_query("SELECT DISTINCT category,intCatID FROM tblcatdetails order by category"); if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT subcategory FROM tblsubcatdetails where intCatID=$cat order by subcategory"); }else{$quer=mysql_query("SELECT DISTINCT subcategory FROM tblsubcatdetails order by subcategory"); } echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['intCatID']==@$cat){echo "<option selected value='$noticia2[category]'>$noticia2[category]</option>"."<BR>";} else{echo "<option value='$noticia2[intCatID]'>$noticia2[category]</option>";} } echo "</select>"; ?> </td></tr> <tr><td><span id="t_subcat">SUB CATEGORY</span></td></tr> <tr><td> <? echo "<select name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>"; } echo "</select>"; ; ?> in this instance I am making an edit page so the selected values already have a value I have tried inserting them in this a number of times and have failed maybe i am too tired. the two values i call from the database $category = $row["category"]; $subcategory = $row["subcategory"]; is it possible to use these values in the above form format? this selection value also has this javascript in the head tags <SCRIPT language=JavaScript> <!-- function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='placead.php?cat=' + val ; } function disableselect() { <? if(isset($cat) and strlen($cat) > 0){ echo "document.postad.subcat.disabled = false;";} else{echo "document.postad.subcat.disabled = true;";} ?> } //--> Link to comment https://forums.phpfreaks.com/topic/138591-selected-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.