Link to home
Start Free TrialLog in
Avatar of sugapablo
sugapablo

asked on

"document.form.submit() is not a function" error?

I've created a simple function:

<script language="javascript">
<!--
    function newAction(newForm) {
        newForm.action = "email.asp";
        newForm.submit();
        return true;
    }
//-->
</script>

Basically, I have two buttons.  One is a "submit" button, and the other, calls this function which is supposed to change the action of the form and submit it.

However, I keep getting a "newForm.submit() is not a function" error. From the JavaScript manual ( http://developer.netscape.com/docs/manuals/communicator/jsref/form1.htm#1010966 ) it appears that my syntax and usage is correct, but alas, no dice.

One thing that does NOT appear to be an issue is that I do not have a button named "submit", nor do I have any element on the page named "submit", so that does not appear to be the problem.

Any suggestions?
Avatar of bobbit31
bobbit31
Flag of United States of America image

how are you calling newAction?
 
Avatar of sugapablo
sugapablo

ASKER

well currently as is: <input name="ss2" type="button" value="Send Email" onClick="newAction()">

But I've tried a variety of other ways such as <input name="ss2" type="button" value="Send Email" onClick="newAction(document.form1)">

I've also written the function as:

<script language="javascript">
<!--
   function newAction() {
       document.form1.action = "email.asp";
       document.form1.submit();
       return true;
   }
//-->
</script>

...but also to no avail.

(name of the form is obviously form1)
Avatar of Zvonko
There is anyway a type in your code, for sure.
First typo in upper postings is that you are calling onClick="newAction()" without a form object.
And if this button is placed on this form named form1, then you can call it better like this:
onClick="newAction(this.form)">

Best would be to post all your code for review.

So long,
Zvonko

ASKER CERTIFIED SOLUTION
Avatar of webcryptix
webcryptix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I must have been 1 sec behind Zvonko
I have done it trying to pass the form in onclick="newAction(document.form1)"  

I'm not using "this.form" because the button is outside of the form itself.


The problem turned out to be that the button in question was outside of the form I wished to use.  That's why I was reluctant to use "this".  But I extended the </form> tag out further, having, in essence, embedded forms and voila. :)
It wasn't exactly the answer, but it DID get me looking in the right place.