webdevguy — 2005-12-21T16:45:11-05:00 — #1
I need to make a cancel button for the form - a button that goes to another page without processing form.
Thanks for your help.
paulyg — 2005-12-21T16:52:22-05:00 — #2
Might depend on what you mean by "cancel".
If its "restore the form to the state it was in when the page loads" youre looking for the straight html RESET in the form. <input type=reset> This in effect is often named "abandon changes" or similar.
If thats not what you mean but some other "go back" action, well its either go back to the server and do a "Header : Location ..." php redirect, or if a JS history.go(-1) type of thing which you'll find in the JS forum I guess..
Else what do you want cancel to do exactly?
stymiee — 2005-12-21T16:53:27-05:00 — #3
<form action="formmail.php" method="post">
<input type="submit" name="submitted" value="cancel">
<input type="submit" name="submitted" value="don't cancel">
if ($_GET['submitted'] == "cancel")
Real basic but it should give you the idea.
paulyg — 2005-12-21T17:00:08-05:00 — #4
@webdevguy et al
Sorry I didnt read that properly.... "a button that goes to another page without processing form."
dreamscape — 2005-12-21T17:03:52-05:00 — #5
if your buttons are images, you can just put a link on the image to the "cancel" page. Not sure why you would POST only to destroy the data and go to another page when you can just outright link to another page.
webdevguy — 2005-12-21T17:13:39-05:00 — #6
what does it matter if I POST or GET.
I think stymiee's will work great in that I will just POST then check the submitted value.
I've been using PEAR Quickform and am going to start rolling my own. Take a look at this link for form submission security - good stuff:
Thanks to everyone.
rodney_h — 2005-12-21T17:22:07-05:00 — #7
You can also make a cancel button like this, using the onClick JS event:
<form name="form" method="post" action="process.php">
<input type="submit" name="submit" value="submit" />
<input type="button" name="cancel" value="cancel" onClick="window.location='http://yoursite.com/index.php';" />
dreamscape — 2005-12-21T18:15:54-05:00 — #8
Why would you POST data just to destroy it on the server and send a redirect? When a normal link is what you want.
POSTing data just to destroy it and redirect just wastes bandwidth.
stymiee — 2005-12-21T19:33:17-05:00 — #9