Gmunky Posted April 12, 2007 Share Posted April 12, 2007 Hello. I have a drop down list : <select> <option>Apple</option> <option>Orange</option> <option>Banana</option> </select> The problem is once an item is selected and the submit button is pressed, the dropdown refreshes and goes back to the first option which is 'Apple' in this case. I want the value picked to stay selected after the submit button is pressed. Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/46722-saving-value-of-a-dropdown-item-after-the-submit-button/ Share on other sites More sharing options...
suzzane2020 Posted April 12, 2007 Share Posted April 12, 2007 do you post back to the same page? if so you need to add these to the select options $value=$_POST[name] <select> <option value="apple"<?php if($value=="apple"){echo "selected";}?>>apple</option> </select> Link to comment https://forums.phpfreaks.com/topic/46722-saving-value-of-a-dropdown-item-after-the-submit-button/#findComment-227626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.