The Praetorian Posted May 10, 2007 Share Posted May 10, 2007 Is there a button for forms to cancel? ( Ie, type="cancel" ) that will send the person back one page? Link to comment Share on other sites More sharing options...
king Posted May 10, 2007 Share Posted May 10, 2007 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 More sharing options...
Anders Moen Posted May 10, 2007 Share Posted May 10, 2007 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 More sharing options...
aspnetguy Posted May 10, 2007 Share Posted May 10, 2007 in JavaScript you could do this <input type="button" value="Cancel" onclick="history.back()"/> Link to comment Share on other sites More sharing options...
reportingsjr Posted May 10, 2007 Share Posted May 10, 2007 oooor: <input type="button" value="Cancel" onclick="history.go(-1)"/> hehe Link to comment Share on other sites More sharing options...
aspnetguy Posted May 10, 2007 Share Posted May 10, 2007 or <input type="button" value="Cancel" onclick="window.location='url to any page you want'"/> Link to comment Share on other sites More sharing options...
jesh Posted May 10, 2007 Share Posted May 10, 2007 or <input type="submit" value="Cancel" onclick="this.form.onsubmit=function() { history.back(); return false; }" /> Link to comment Share on other sites More sharing options...
aspnetguy Posted May 10, 2007 Share Posted May 10, 2007 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 More sharing options...
Skemcin Posted May 10, 2007 Share Posted May 10, 2007 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 More sharing options...
jesh Posted May 10, 2007 Share Posted May 10, 2007 I have no response to this *shakes head in disbelief*As crazy as that is it would work, not exactly best practice thoughHah! 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 More sharing options...
The Praetorian Posted May 11, 2007 Author Share Posted May 11, 2007 Thanks guys. I used the latter one because I like the confirmation question. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.