File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Forcing a submit on a timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Forcing a submit on a timeout" Watch "Forcing a submit on a timeout" New topic

Forcing a submit on a timeout

scott dawson

Joined: Jun 30, 2003
Posts: 18
Is there a way that I can set a timer that will submit a form when it expires? The closest way I have now is to set the .href property of the location object, but this isn't really the same as if I could simulate an onClick event. Is this possible from Javascript.
Another alternative is to set a timer in the controller servlet (using an MVC2 arch), and if the timer goes off simulate a submit.. I'd really like to control this from the client end though.
Thanks , and hope this makes sense.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
If you want to submit a form, then all you need to do is the following line of code
himanshu patel
Ranch Hand

Joined: Feb 03, 2003
Posts: 205
Just check this code.Might serve your purpose.
function setTimeForSubmit(){
window.setTimeout("submitForm()",20000);//Expire after 20 Sec
function submitForm(){
<BODY onload="setTimeForSubmit()">
<FORM name="myForm" method="post" action = "somefile.html">
[ February 09, 2004: Message edited by: himanshu patel ]

If you want to become a rich, do not work for others but make others to work for you.
I agree. Here's the link:
subject: Forcing a submit on a timeout
It's not a secret anymore!