BillyMako Posted August 20, 2008 Share Posted August 20, 2008 When i select something from the drop down list it is not passing it to the next page. <tr><?php @$suburb=$_GET['suburb']; ?> <td class="main"><?php echo ENTRY_SUBURB; ?></td> <td class="main"><?php echo "<select name='suburb'><option value='$suburb'>Select Suburb</option>"; // onchange=\"reload(this.form)\" while($pop = mysql_fetch_array($query)) { if($pop['postcode']==@$suburb){ echo "<option value='$pop[postcode]'>$pop[suburb]</option>"; }else{ echo "<option selected value='$suburb'>$pop[suburb]</option>";} } echo "</select>"; ?> * Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/ Share on other sites More sharing options...
bretticus Posted August 20, 2008 Share Posted August 20, 2008 So... Are you using method="get"? Are those error suppressors in front of "@$suburb". Why are you doing that? Now... It might be that in the following code: <?php if($pop['postcode']==@$suburb){ echo "<option value='$pop[postcode]'>$pop[suburb]</option>"; }else{ echo "<option selected value='$suburb'>$pop[suburb]</option>"; } ?> You are telling it to print out an ordinary option WHEN they match. Shouldn't your code be: <?php if($pop['postcode']==$suburb){ echo "<option selected value='$suburb'>{$pop['suburb']}</option>";} }else{ echo "<option value='{$pop[postcode]}'>{$pop['suburb']}</option>"; } ?> Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620878 Share on other sites More sharing options...
iversonm Posted August 20, 2008 Share Posted August 20, 2008 you never closed your while statement unless its just a type when you submited this Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620879 Share on other sites More sharing options...
BillyMako Posted August 20, 2008 Author Share Posted August 20, 2008 Still not working Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620882 Share on other sites More sharing options...
bretticus Posted August 20, 2008 Share Posted August 20, 2008 Still not working You better post some more code and any error messages then. My crystal ball is in the washing machine Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620883 Share on other sites More sharing options...
bretticus Posted August 20, 2008 Share Posted August 20, 2008 you never closed your while statement unless its just a type when you submited this It's closed. The else close comes right after the last echo statement. Perfectly positioned to confuse everyone Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620884 Share on other sites More sharing options...
BillyMako Posted August 20, 2008 Author Share Posted August 20, 2008 It's cut down now, still works but wont hold the value when form is submitted.???? echo"Suburb: "; echo "<select name='suburb'><option value='$suburb'>Select Suburb</option>"; // onchange=\"reload(this.form)\" while($pop = mysql_fetch_array($query)) { echo "<option value='$pop[postcode]'>$pop[suburb]</option>"; } echo "</select>"; Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620888 Share on other sites More sharing options...
BillyMako Posted August 20, 2008 Author Share Posted August 20, 2008 Got it working now! echo"Suburb: "; echo "<select name='suburb'><option>Select Suburb</option>"; // onchange=\"reload(this.form)\" while($pop = mysql_fetch_array($query)) { echo "<option>$pop[suburb]</option>"; } echo "</select>"; Link to comment https://forums.phpfreaks.com/topic/120483-drop-down-menu-not-keeping-value/#findComment-620891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.