cancel button in html form

Rated 4.67 By 3 users
souri_sen's Avatar, Join Date: Jan 2009
Newbie Member
Hello all, I have a problem to create a form's cancel button. It will be appreciable if anybody help me.

The code is about the cancel button, im actully making a form which has a cancel button. If the button is pressed it will redirect in another page.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Write the code in the OnClick Event to redirect the page to other url. Something similar to the Go Advanced button in the quick reply
skp819's Avatar
Contributor
Hope that links will help you............

http://www.useit.com/alertbox/20000416.html

http://devedge-temp.mozilla.org/libr...de/tags10.html
vks21's Avatar, Join Date: Feb 2009
Light Poster
I am not sure about this But you should try it yourself..perhaps it works correctly..Good luck.
Code:

object.Cancel
akshits's Avatar, Join Date: May 2009
Go4Expert Member
Below is a code help for you:-

Code:
<script>
function $(id) { return document.getElementById(id); }
</script>

<form action="...php" id="frm">

[CODE here]

<input type="submit" value="Submit form">
<button onclick="$('frm').action='otherPage.php';$('frm').submit();">Cancel</button>

[CODE here]

</form>
Regards,
Akshit Soota
akras14's Avatar, Join Date: Aug 2009
Newbie Member
<input type="button" name="Cancel" value="Cancel" onclick="window.location = 'yourpage.html' " />
GreatGizzards's Avatar, Join Date: Nov 2010
Newbie Member
<a href="url.html"><input type="button" name="cancel" value="Cancel" /></a>

This ones particularly nice because it only depends on html
a-nerd-in-time's Avatar, Join Date: Dec 2012
Newbie Member
GreatGizzards, thank you!
works perfectly and I also wanted to mention that I needed to re-direct to a php file to instead of url.html, I entered home.php and bingo, it worked.