Thread: onSubmit

  1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Can anyone tell me why (contradicting what other people say) I can't change the URL in the onSubmit handler? Here's what I'm doing:

    <FORM NAME="test" METHOD="POST">
    <INPUT TYPE="submit" NAME="btn" VALUE="Click me"

    According to everything I've read, this should work. In fact, it works if I change it to a button (TYPE="button") and use the onClick handler (onClick=...)!

    I am testing it in Netscape 4.5, by the way.

    Graham Stratford
  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Hiya Graham,

    I reckon you've been misled. AFAIK, onSubmit is only valid in the <FORM> tag, and will only work if you use a submit input field. So you can either use:

    <form action="whatever" name="test" method="POST" onSubmit="JavaScript()">
    <input type="submit" value="Submit">


    <form action="whatever" name="test" method="POST">
    <input type="button" value="Submit" onClick="JavaScript()">

    I think you can use <input type"submit"... in the second one too, the onClick event handler will negate it. Probably best using ; return false after the JavaScript in the onClick statement if you are though.

  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Thanks enormously, Adam. I'll try your suggestions and see how it goes.


    P.S. One of my friends used to call me "Grahamster the hamster." Your nick brought that back to me!
  6. #4
  7. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Well, I tried what you suggested, and. . .

    it didn't work. Other JavaScript commands worked fine, but changing parent.location didn't. I checked a bunch of on-line references, and -- curiously enough -- NONE of them were changing parent.location in the onSubmit handler.

    What DOES seem to work is changing the Submit button to a normal button, and in the onClick handler calling document.form[0].submit(). What a goofy situation.

  8. #5
  9. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    This is really annoying. IE 4.01 will pop up the message box about a security risk (something about sending an unencrypted e-mail), but NOT send anything!

    Netscape just doesn't send anything.

    BOTH browsers will change the location correctly!!!! I am I going insane?

    Here's my test form:

    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Mozilla/4.6 [en] (Win95; I) [Netscape]">
    <title>JavaScript - onSubmit Event</title>
    <SCRIPT LANGUAGE="JavaScript">
    function SubmitForm(form)


    <body bgcolor="#FFFFFF">
    <FORM ACTION="" ENCTYPE="text/plain"
    NAME="testform" METHOD="POST">
    <INPUT TYPE="text" NAME="Nothing" VALUE="Help!" SIZE="20" MAXLENGTH="0">
    <INPUT TYPE="button" NAME="btn" VALUE="Click me"
  10. #6
  11. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Hmmm. I just found out that does NOT WORK when using the mailto: method!

    Actually, IE tried to send the e-mail, but didn't complete, since Netscape Messenger put the e-mails into my "Drafts" folder.

    That means I'll have to find some way to change the page in the onSubmit event.


Similar Threads

  1. multiple events with onSubmit
    By thuynh7 in forum HTML Programming
    Replies: 4
    Last Post: October 27th, 2004, 07:54 PM
  2. Two onsubmit values in <form>
    By zeuseason in forum Java Help
    Replies: 5
    Last Post: November 5th, 2003, 01:02 PM
  3. onSubmit Question
    By ailen in forum HTML Programming
    Replies: 2
    Last Post: September 23rd, 2003, 08:00 PM
  4. onSubmit with window.close() ?
    By robpet in forum HTML Programming
    Replies: 2
    Last Post: February 19th, 2002, 01:37 AM
  5. Execute onSubmit() event handler from form.submit()
    By cjtucker in forum HTML Programming
    Replies: 2
    Last Post: December 10th, 2001, 11:54 AM

IMN logo majestic logo threadwatch logo seochat tools logo