ryanwood4 Posted January 18, 2010 Share Posted January 18, 2010 I'm trying to get a select box to show the result stored in a database as the default, but the value="<? echo $repeat?>"> function doesn't work. Example: User selects Repeat, saves there choice, then comes back to change it, it will show No-Repeat, rather than Repeat. <select name="repeat" size="1" id="repeat" value="<? echo $repeat?>"> <option value="no-repeat">No-Repeat</option> <option value="repeat">Repeat</option> <option value="repeat-x">Horizontally</option> <option value="repeat-y">Vertically</option> </select> Any help is greatly appreciated, it might be so simple, and if it is, I apologise. Thanks. Link to comment https://forums.phpfreaks.com/topic/188907-echo-chosen-selection-in-select-drop-down-box/ Share on other sites More sharing options...
Buddski Posted January 18, 2010 Share Posted January 18, 2010 <select name="repeat" size="1" id="repeat"> <option value="no-repeat" <?php echo ($repeat == 'No-Repeat' ? 'selected="selected"' : '');?>>No-Repeat</option> <option value="repeat" <?php echo ($repeat == 'repeat' ? 'selected="selected"' : '');?>>Repeat</option> <option value="repeat-x" <?php echo ($repeat == 'repeat-x' ? 'selected="selected"' : '');?>>Horizontally</option> <option value="repeat-y" <?php echo ($repeat == 'repeat-y' ? 'selected="selected"' : '');?>>Vertically</option> </select> Should do the trick Link to comment https://forums.phpfreaks.com/topic/188907-echo-chosen-selection-in-select-drop-down-box/#findComment-997378 Share on other sites More sharing options...
ryanwood4 Posted January 18, 2010 Author Share Posted January 18, 2010 That did the trick! Thank you very much. Link to comment https://forums.phpfreaks.com/topic/188907-echo-chosen-selection-in-select-drop-down-box/#findComment-997389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.