Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 29th, 2006, 08:05 PM
antonyliu2002@yahoo.com
Guest
 
Posts: n/a
Default 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.

  #2  
Old September 29th, 2006, 09:35 PM
VK
Guest
 
Posts: n/a
Default Re: document.getElementById('myForm').submit() does not work


antonyliu2002@yahoo.com wrote:
Quote:
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).

  #3  
Old September 30th, 2006, 02:55 AM
antonyliu2002@yahoo.com
Guest
 
Posts: n/a
Default Re: document.getElementById('myForm').submit() does not work

VK wrote:
Quote:
antonyliu2002@yahoo.com wrote:
Quote:
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.

  #4  
Old September 30th, 2006, 04:25 AM
RobG
Guest
 
Posts: n/a
Default Re: document.getElementById('myForm').submit() does not work


antonyliu2002@yahoo.com wrote:
[,,,]
Quote:
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

  #5  
Old September 30th, 2006, 05:05 AM
antonyliu2002@yahoo.com
Guest
 
Posts: n/a
Default Re: document.getElementById('myForm').submit() does not work

RobG wrote:
Quote:
antonyliu2002@yahoo.com wrote:
[,,,]
Quote:
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.

  #6  
Old September 30th, 2006, 12:05 PM
RobG
Guest
 
Posts: n/a
Default Re: document.getElementById('myForm').submit() does not work


antonyliu2002@yahoo.com wrote:
Quote:
RobG wrote:
Quote:
antonyliu2002@yahoo.com wrote:
[,,,]
Quote:
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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles