Page 1 of 1

HTML forms. different buttons, different actions

Posted: Wed Nov 29, 2006 10:27 am
by boo_lolly
hello all, i'm building a CMS and i'm have some trouble with a certain page i've been working on. I have information stored in my database that the admin user can edit and update and change, obviously. on this edit page i have HTML input fields that have been pre-populated with the variable values.

underneath all of that, i have 3 html submit buttons. one of them is "Cancel", another is "Save and Exit", and the last is "Save and Continue".

if the admin presses cancel, i want to keep the values that are already stored in the database, and go to a certain page.

if the admin presses save and exit, i want all the changes that have been made to update the database, and then go to a certain page.

if the admin presses save and continue, i want all the changes that have been made to update the database, and then go to a different page.

got it? how do i do this? i was thinking wrapping it all up in one html form, and replacing action= with action=<?php echo $submit_value ?> or something like that. and on each submit button the name could be the value of $submit_value. maybe with some if() statements. i dunno. help!

Posted: Wed Nov 29, 2006 10:33 am
by Burrito
if javascript is an option, I'd write a new value to a hidden form var and then handle the request on the action page accordingly.

Posted: Wed Nov 29, 2006 10:58 am
by boo_lolly
nah, unfortunately javascript isn't an option however i DID think of that. what i believe i'm going to end up doing is adding if() and elseif() statements at the top of the forwarding pages to see which one was clicked, and then take a certain action depending on which one was clicked. dirka.

Posted: Wed Nov 29, 2006 11:02 am
by Burrito
make sure you test it in all browsers, some browsers handle button clicking differently.

Posted: Wed Nov 29, 2006 11:16 am
by boo_lolly
GOOD call burrito! thanks for the tip! happy tokin'!

Posted: Wed Nov 29, 2006 11:42 am
by John Cartwright
boo_lolly wrote:happy tokin'!
8O

Posted: Wed Nov 29, 2006 1:26 pm
by boo_lolly
Jcart wrote:
boo_lolly wrote:happy tokin'!
8O
maple leaf indica =)