472,328 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

document.getElementById('myForm').submit() does not work

Hi,

It looks like so many people are having problems with the javascript
submit in firefox. I searched around, but haven't found a solution
yet. Mostly, people were saying, try this or try that or maybe blah
blah or why do you wanna do that blah blah. I haven't seen a solution
to this problem.

OK, I am trying to share session objects between classic asp
applications and asp.net applications. If you insist in asking why I
wanna do this, because a big chunk of our web application was written a
few years ago in classic ASP, and I am gonna add new components to it
in ASP.NET (I don't wanna write in classic ASP).

So, I searched and found a very good solution to this problem at
http://www.eggheadcafe.com/articles/20021207.asp

That is a great strategy, but the automatic submit by the javascript
(shown below where 't' is the id of the form) in the hidden page works
for IE, but not for firefox.

<script>t.submit();</script>

Please note that this is intended to *automatically* submit, in other
words, there are no button clicks.

I tried instead

document.getElementById(t).submit(); and
document.getElementById('t').submit(); and
(document.getElementById('t')).submit();

None of these worked for firefox.

I believe many out there are having the same problem. Any solution
yet? Thanks.

Sep 29 '06 #1
5 76753
VK

an***********@yahoo.com wrote:
That is a great strategy, but the automatic submit by the javascript
(shown below where 't' is the id of the form) in the hidden page works
for IE, but not for firefox.
Check for two of the most common mistakes:

1) You form has *name* "t" and not id "t" - then naturally
getElementById is out of business here.

2) Your submit button in the form is called "submit":
<input type="submit" name="submit"...Some badly written authoring
tools still do it by default and it nukes dot-based method accessor for
form submit.

3) The autoreferencing of ID'ed elements in the global scope is IE's
invention. Firefox alas does it too but in quirk mode. Use DOM 0 form
access methods, they are still the best (and no global scope
pollution):
<form name="t" action="...">

and then

document.forms['t'].submit()

or (if in another frame):

parent.frames['frameName'].document.forms['t'].submit()

If the problem persists it may be needed to see the relevant fragment
of your page (or a link).

Sep 29 '06 #2
VK wrote:
an***********@yahoo.com wrote:
That is a great strategy, but the automatic submit by the javascript
(shown below where 't' is the id of the form) in the hidden page works
for IE, but not for firefox.

Check for two of the most common mistakes:

1) You form has *name* "t" and not id "t" - then naturally
getElementById is out of business here.

2) Your submit button in the form is called "submit":
<input type="submit" name="submit"...Some badly written authoring
tools still do it by default and it nukes dot-based method accessor for
form submit.

3) The autoreferencing of ID'ed elements in the global scope is IE's
invention. Firefox alas does it too but in quirk mode. Use DOM 0 form
access methods, they are still the best (and no global scope
pollution):
<form name="t" action="...">

and then

document.forms['t'].submit()

or (if in another frame):

parent.frames['frameName'].document.forms['t'].submit()

If the problem persists it may be needed to see the relevant fragment
of your page (or a link).
Hi, VK, thanks a lot for your hint. I tried exactly as you instructed.
It still does not work. This one is really hard. Not sure why
Firefox does this.

Sep 30 '06 #3

an***********@yahoo.com wrote:
[,,,]
Hi, VK, thanks a lot for your hint. I tried exactly as you instructed.
It still does not work. This one is really hard. Not sure why
Firefox does this.
Post an example where Firefox doesn't do "this" and IE does. Then
you'll get some precise help, rather than guesses.

The following example works in Firefox:

<form name="fred" action="">
<input type="text" value="blah" name="blahInput">
</form>

<a href="#" onclick="document.forms['fred'].submit();">Submit the form
"fred"</a>
Which shows that calling a form's submit method works, therefore the
error is elsewhere.
--
Rob

Sep 30 '06 #4
RobG wrote:
an***********@yahoo.com wrote:
[,,,]
Hi, VK, thanks a lot for your hint. I tried exactly as you instructed.
It still does not work. This one is really hard. Not sure why
Firefox does this.

Post an example where Firefox doesn't do "this" and IE does. Then
you'll get some precise help, rather than guesses.

The following example works in Firefox:

<form name="fred" action="">
<input type="text" value="blah" name="blahInput">
</form>

<a href="#" onclick="document.forms['fred'].submit();">Submit the form
"fred"</a>
Which shows that calling a form's submit method works, therefore the
error is elsewhere.
--
Rob
Thanks. Rob,

The problem seems to be this: I need to include

<html><head><title>Test</title></head><bodybefore <formand then
</body></htmlafter </form>

for firefox to work. Whereas, IE does not care about "incomplete" HTML
page.

I tried this, if I don't make the HTML page complete with those basic
tags, then Firefox won't work for this snippet of code, otherwise, it
works.

A great lesson to learn.

Sep 30 '06 #5

an***********@yahoo.com wrote:
RobG wrote:
an***********@yahoo.com wrote:
[,,,]
Hi, VK, thanks a lot for your hint. I tried exactly as you instructed.
It still does not work. This one is really hard. Not sure why
Firefox does this.
Post an example where Firefox doesn't do "this" and IE does. Then
you'll get some precise help, rather than guesses.

The following example works in Firefox:

<form name="fred" action="">
<input type="text" value="blah" name="blahInput">
</form>

<a href="#" onclick="document.forms['fred'].submit();">Submit the form
"fred"</a>
Which shows that calling a form's submit method works, therefore the
error is elsewhere.
--
Rob

Thanks. Rob,

The problem seems to be this: I need to include

<html><head><title>Test</title></head><bodybefore <formand then
</body></htmlafter </form>

for firefox to work. Whereas, IE does not care about "incomplete" HTML
page.
There must be more to this than you've posted - head, body and HTML
tags are all optional. The code that I posted works in Firefox even it
that's all that's in the page. Add a doctype and title element and
it's valid HTML.
--
Rob

Sep 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Chris | last post by:
Heres my problem: <a href="javascript:void(document.buysell.submit())" target="_parent"...
3
by: Don | last post by:
I can successfully force submission of a <form> using "document.formname.submit()". But, the submission doesn't appear to occur when used with...
2
by: Alex | last post by:
Hello, I use the following script inside a page. My page contains : 1 FORM, Some Hidden fields, and one line of JAVASCRIPT in order to instantly...
5
by: terence.parker | last post by:
I have a PHP application which I wrote last year - and the JavaScript worked fine then. For some reason, now it doesn't - neither on IE nor...
8
by: Ed Jay | last post by:
Is there a way to use 'document.form.submit()' to submit a form to a url other than that specified in the Form element? -- Ed Jay (remove M to...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't...
2
by: alan_atwood | last post by:
Hello all. I am having a problem with the submit() method that is driving me nuts. I'm using document.form.submit() with large text fields...
5
by: therjs | last post by:
i am trying to submit the form multipple times within a loop, if i have an alert() coded, it works, but, when i take the alert() out, it only does...
2
by: Arif Bangash | last post by:
Hi All, I have a form like this <form id="frmworld" name ="frm" method=POST action "https://select.worldpay.com/wcc/purchase" > <input...
7
by: vinsim24 | last post by:
Hi all, the code where i am finding a problem is as follows: <html> <head> <script> function fun1(){...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.