I want to create form which can submit data automatically, without using submit button. I need something like this http://www.bontragercgi.com/Automatic_Form_Submission_to_a_CGI_Program.html <script type="text/javascript" language="JavaScript"><!-- document.MyForm.ThisPageURL.value = document.URL; var visitortime = new Date(); document.MyForm.TimeZoneOffset.value = visitortime.getTimezoneOffset(); document.MyForm.submit(); //--></script> Code (markup): <form name="MyForm" method="POST" action="/cgi-bin/script.cgi"> <input type="hidden" name="ThisPageURL" value=""> <input type="hidden" name="TimeZoneOffset" value=""> </form> Code (markup): But this doesn't work. Thanks in advance for your help.
Any error in the console? Did you follow this instruction: "Put the JavaScript somewhere below the form." ?
OOps this was the problem. I was adding the javascript at the top of page between <head> and </head> tags. Thanks.
Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be set with php variables). <form action="page.php" method="post"> <input type="text" name="example1" value="<?php echo $_POST['something1'];?>" /> <input type="text" name="example2" value="ANOTHER_YOUR_VALUE" /> <input type="submit" /> </form> <SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT> Code (markup): for example, the $_POST['something1'] value is received from the previous real-user submited Form, and this form can add another input with ANOTHER_YOUR_VALUE. _______________________
The thread is 5-1/2 years old. If he hasn't solved it by now, I don't think he cares how to solve it.