Jump to content

[SOLVED] Keeping selections on dropdown selection-boxes


TEENFRONT

Recommended Posts

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?

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>';

 

}

 

?>

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.