TEENFRONT Posted April 10, 2007 Share Posted April 10, 2007 Title says it all lol! I have a article manager script that im nearly done with and when you press save, it takes you to another page to check that you have entered the required fields by checking for the POST vars, if not it redirects back to the page and stuffs the entered fields into GET vars header( location: file.php?errors=$errors&var1=$var1 ) 's you back to the previous page. Now i have no trouble reshowing the entered info in regular text fields as i grab it from GET but i dont seem to be able to reshow a drop down box selection it always reverts back to the first option when i redirect the page.. any help? Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/ Share on other sites More sharing options...
JSHINER Posted April 10, 2007 Share Posted April 10, 2007 I created a table in my database that in this case contained "categories" - then: <?php foreach ($page['categories'] as $c) { echo '<option value="', $c['id'], '"'; if ($_POST['id'] == $c['id']) { echo ' selected="selected"'; } echo '>', $c['name'], '</option>'; } ?> Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/#findComment-226228 Share on other sites More sharing options...
TEENFRONT Posted April 10, 2007 Author Share Posted April 10, 2007 Hey , thanks for the above. I didnt want to use the database untill all the info had been entered. So for this i have just asked the user to press back to correct the errors, and not redirect them, this way i dont loose the entered text and selections. Cheers! Solved! Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/#findComment-226240 Share on other sites More sharing options...
JSHINER Posted April 10, 2007 Share Posted April 10, 2007 Be careful - some browsers erase the form fields when you hit back. Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/#findComment-226248 Share on other sites More sharing options...
TEENFRONT Posted April 10, 2007 Author Share Posted April 10, 2007 As far as i know IE and FF dont erase the form fields and it will only be me and my site team that use this manager. Thanks again. Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/#findComment-226259 Share on other sites More sharing options...
JSHINER Posted April 10, 2007 Share Posted April 10, 2007 Good stuff. Hit SOLVED. Link to comment https://forums.phpfreaks.com/topic/46496-solved-keeping-selections-on-dropdown-selection-boxes/#findComment-226263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.