The onSubmit Event

This Event Handler allows users to make the page change when they click on a Submit buttond. It might change to just a simple page that says "Thanks A Lot!," but people seem to think they need this wonderful effect on their website. Unfortunately, I cannot get it to work here, nor does this work on the answer website. I had to look online for the correct code for this one:

HTML file: Displayed by browser:
<body>

<H4>#1 -- This does not work:<H4>
<FORM>
<INPUT TYPE="submit"
    onSubmit="alert('thanxalot.html')";>
</FORM>
<HR />
<H4>#2 -- This does not work either:<H4>
<FORM>
<INPUT TYPE="submit"
    onSubmit="location.href='thanxalot.html'">
</FORM>
<HR />
<H4>#3 -- Gee, this one will not work either:<H4>
<FORM>
<INPUT TYPE="submit"
    onSubmit="parent.location='thanxalot.html'";>
</FORM>
<HR />
<H4>#4 -- By golly, FINALLY hit the motherload! This one works:<H4>
<FORM ACTION="thanxalot.html">
<INPUT TYPE="submit" value="Yay, I am working!">
</FORM>

</body>

#1 -- This does not work:


#2 -- This does not work either:


#3 -- Gee, this one will not work either:


#4 -- By golly, FINALLY hit the motherload! This one works:

The textbook that I'm learning from is from 1999, so it might be outdated. The book suggested the first forms, and the website advised doing Form #2 and #3, but none of those forms (the first three) work. Clicking on the submit button just keeps the user at this page. I can't get it to go to the other webpage "thanxalot.html", until I set it up like #4. (Had to go online to find this.)

BackTable of ContentsNext