?
Solved

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

Posted on 2003-02-19
8
Medium Priority
?
2,505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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!

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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

762 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