473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Question about submit form in Javascript

LeoTD
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
4 1454
acoder
16,027 Expert Mod 8TB
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
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
101 100+
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
16,027 Expert Mod 8TB
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

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

Similar topics

3
by: Freeserve | last post by:
Hi, I have a form with some fields and a submit button. The submit button posts the results to itself, which are then processed. I have 2 questions: 1. Is it possible to have a series of...
10
by: Oli | last post by:
Hi Folks, Alright, I have a textbox called "A" and the value in that textbox is "B". When the user presses submit I want A : B to appear on the page. How do I do it? I appreciate that this...
3
by: Matt | last post by:
When the user click the submit button in myform.asp, then it will invoke the javascript to check the form data. I want to know if we need document.myform.submit(); ?? Because even I comment it...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
8
by: Workgroups | last post by:
I've got a page where the nature of the beast is such that the user clicks a submit button to ransomize some data in somewhat rapid succession (once per second, give or take). The page generates a...
7
by: Bruno Alexandre | last post by:
Hi guys, Sorry about the off topic, but I can't find the ASP group just the ASP dot NET If I want to block a user to change a form after submiting, I add a function that will disable the...
2
by: khng | last post by:
When there is a HTML Form with lots of input elements, how can I know which element is triggering the form submit action with the help of javascript.
7
by: David T. Ashley | last post by:
Hi, For a web page, I want a SUBMIT button that commits the form data and a CANCEL button that goes to a different target (i.e. a different script). I haven't figured out how to do this,...
14
by: Mtek | last post by:
Hi, We have a form defined with buttons like this: <a class="save_menu" href="javascript:document.Detail_Screen.action = 'savedata.php?screen=EDIT';document.Detail_Screen.submit();">Update</...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.