Jump to content

Cancel button for forms?


The Praetorian

Recommended Posts

Is there a button for forms to cancel? ( Ie, type="cancel" ) that will send the person back one page?
Nope. If you want to have a cancel button, you have to make it yourself.
Link to comment
Share on other sites

JavaScript prompt does this, but I don't know how to get it into the form..But if you can use PHP:

<?phpif (isset($_POST['cancel'])) {header('Location: back_to_the_previous_site.php');die('');}?><form action="" method="post"><input type="submit" name="submit" value="Submit" /><input type="submit" name="cancel" value="Cancel" /></form>

***The PHP-code must be over the doctype and it only works if you can use PHP!

Link to comment
Share on other sites

or

<input type="submit" value="Cancel" onclick="this.form.onsubmit=function() { history.back(); return false; }" />

:)

Link to comment
Share on other sites

or
<input type="submit" value="Cancel" onclick="this.form.onsubmit=function() { history.back(); return false; }" />

:)

I have no response to this *shakes head in disbelief*As crazy as that is it would work, not exactly best practice though
Link to comment
Share on other sites

or

<input type="button" value="Cancel" onclick="alert('Action Cancel.\nClick OK to continue.'); window.location='yourpage.htm'"/>

:)

Link to comment
Share on other sites

I have no response to this *shakes head in disbelief*As crazy as that is it would work, not exactly best practice though
Hah! I tried to get even more elaborate but it turns out there are security issues with accessing the history objects properties. Oh well.How about:
<input type="button" value="Cancel" onclick="if(confirm('Are you SURE you wish to cancel?')) history.back();" />

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...