AshmanSNET Posted October 12, 2007 Share Posted October 12, 2007 Hi, I have a drop down list which I want to be set to what was selected when the form is submitted. As the form is processed by the same page, it returns to the preset default. How would I go about making this selection box set the option selected on the next page? Thanks Ash Link to comment https://forums.phpfreaks.com/topic/72877-solved-setting-selected-option-using-php/ Share on other sites More sharing options...
onenonly Posted October 12, 2007 Share Posted October 12, 2007 <?php echo '<select name="gender">'; echo '<option value="male"'; if (strtolower($_POST['gender']) == 'male') echo ' selected="selected"'; echo '>Female</option>'; echo '</select>'; echo '<input type="submit" value="Submit" name="submit"></td></tr>'; echo '</table>'; echo '</form>'; ?> Link to comment https://forums.phpfreaks.com/topic/72877-solved-setting-selected-option-using-php/#findComment-367579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.