?
Solved

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

Posted on 2003-02-19
8
Medium Priority
?
2,515 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:sugapablo
8 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7982628
how are you calling newAction?
 
0
 

Author Comment

by:sugapablo
ID: 7982676
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)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 7982853
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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
webcryptix earned 200 total points
ID: 7982857
You are missing your refrence to your form.

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

will work if you have something like this...

<input type="button" value="Click Here" onclick="newAction(this.form)" />


0
 

Expert Comment

by:webcryptix
ID: 7982861
I must have been 1 sec behind Zvonko
0
 

Author Comment

by:sugapablo
ID: 7982905
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.


0
 

Author Comment

by:sugapablo
ID: 7983060
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. :)
0
 

Author Comment

by:sugapablo
ID: 7983076
It wasn't exactly the answer, but it DID get me looking in the right place.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question