I am playing with the Buttons in the w3schools Tryit editor, and I am trying to figure out how to make my browser redirect to an URL when I click on the "Cancel" button.
Here's what I have tried:
<form action="demo_form.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
cancel is not a valid value for a type attribute, so the button is probably defaulting to
submit and continuing to submit the form. You probably mean
You don't have any button-like functionality though, so would be better off with:
<a href="http://stackoverflow.com"> Cancel </a>
… possibly with some CSS to make it look like a button.