By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

Question about submit form in Javascript

LeoTD
P: 14
Dear all,
I'm newbiew in Javascritp, i have a question about submit form automatically. Here is my code:

[HTML]<form id="frmTest" action="www.example.com" method="post">
<input type="hidden" name="test" value="testvalue" />
<script type="text/javascript">
document.getElementById("frmTest").submit();
</script>
</form>
[/HTML]
It execute good in IE, but when I use Firefox it not run and show error:
Error: document.getElementById("frmTest") has no properties
Line: 4

Please help me fix it,
Thanks a lot!!
Nov 5 '07 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
Please use code tags when posting code:

[CODE=javascript]
Your JavaScript code goes here...
[/code]

Move the script to outside the form tags, i.e. after the closing form tag.
Nov 5 '07 #2

LeoTD
P: 14
Please use code tags when posting code:

Expand|Select|Wrap|Line Numbers
  1. Your JavaScript code goes here...
  2.  
Move the script to outside the form tags, i.e. after the closing form tag.
Dear acoder,

Thank you for helping me, i have fixed it.

Best regards,
Leo
Nov 6 '07 #3

Ferris
100+
P: 101
hi

[HTML]
<form id="frmTest" action="http://www.example.com" method="post">
<input type="hidden" name="test" value="testvalue" />
</form>
<script language="javascript" type="text/javascript">
document.getElementById("frmTest").submit();
</script>
[/HTML]

hope it helps.
Nov 6 '07 #4

acoder
Expert Mod 15k+
P: 16,027
Dear acoder,

Thank you for helping me, i have fixed it.

Best regards,
Leo
Glad to hear that you got it working. Post again if you have more questions.
Nov 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.