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?
<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?
how are you calling newAction?
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(documen t.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)
But I've tried a variety of other ways such as <input name="ss2" type="button" value="Send Email" onClick="newAction(documen
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)
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.fo rm)">
Best would be to post all your code for review.
So long,
Zvonko
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.fo
Best would be to post all your code for review.
So long,
Zvonko
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I must have been 1 sec behind Zvonko
ASKER
I have done it trying to pass the form in onclick="newAction(documen t.form1)"
I'm not using "this.form" because the button is outside of the form itself.
I'm not using "this.form" because the button is outside of the form itself.
ASKER
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. :)
ASKER
It wasn't exactly the answer, but it DID get me looking in the right place.