I can run the following javascript code succefully in IE browser:

<script language="JavaScript" type="text/JavaScript">

this javascript automatically submit the form when running the page.

However I have problem in Firefox browser, it's stuck at this code (cannot submit form).

Any idea what I need to modify so it works both on IE and Firefox? thanks.

IE can use the forms name element to identify the form. I hope that the same is not true for firefox. but I think in firefox and IE you can use the forms ID attribute ( the form should still have a name!! ).

I prefer to use this technique:

var formToSend = document.getElementById("formId");

This technique should work on all browsers that have JavaScript enabled.

I know this is over a year old, but I'd like to update the response for any googlers. The following will work in all major browsers: document.formname.submit(); where "formname" is the same as the form's "name" attribute.

OR document.getElementById('formid').submit(); where "formid" is the same as the form's "id" attribute.

Again, either code will work, and it's preferable to keep your code clean by removing unnecessary code/lines (like where the previous poster created a variable and then submitted that variable).


I think alpha_foobar has written code in more cleaner way than joequincy. Its always better to declare variable and gave them good name so that it can understand by others.

formToSend.submit(); is more meaningfull than documnt.getElementById(formid).submit();

Always write code so that anyone can understand it easily.