•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,946 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,915 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 8085 | Replies: 3
![]() |
•
•
Join Date: Jun 2005
Posts: 85
Reputation:
Rep Power: 4
Solved Threads: 0
I can run the following javascript code succefully in IE browser:
<script language="JavaScript" type="text/JavaScript">
document.formname.submit();
</script>
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.
<script language="JavaScript" type="text/JavaScript">
document.formname.submit();
</script>
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.
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
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:
This technique should work on all browsers that have JavaScript enabled.
I prefer to use this technique:
var formToSend = document.getElementById("formId");
formToSend.submit();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:
OR
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).
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).
•
•
Join Date: Aug 2006
Location: Noida, India
Posts: 152
Reputation:
Rep Power: 3
Solved Threads: 16
Hi,
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.
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.
When you think you have done a lot, then be ready for YOUR downfall.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax asp beta bon browser browsers browsing developer development echo email encryption europe firefox gecko home html internet internet explorer internet explorer 7 javascript leak linux memory microsoft mozilla msdn networking news office open source open-source patch phishing scams security site social software sql super testing users vista web webmail
- Why javascript does not work on firefox? (JavaScript / DHTML / AJAX)
- Javascript not working in Firefox (JavaScript / DHTML / AJAX)
- How to correct this javascript UNDER Mozilla Firefox? (JavaScript / DHTML / AJAX)
- javascript in mozilla firefox (JavaScript / DHTML / AJAX)
- Javascript not working in Firefox (JavaScript / DHTML / AJAX)
- Javascript problem in FIREFOX (JavaScript / DHTML / AJAX)
- Javascript Problem with Firefox (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Code to populate pages with multiple artists?
- Next Thread: template management of the website


Linear Mode