aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Forcing a submit on a timeout" Watch "Forcing a submit on a timeout" New topic
Author

Forcing a submit on a timeout

scott dawson
Greenhorn

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.
Scott
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If you want to submit a form, then all you need to do is the following line of code
document.FormName.submit();
Eric
himanshu patel
Ranch Hand

Joined: Feb 03, 2003
Posts: 205
Just check this code.Might serve your purpose.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function setTimeForSubmit(){
window.setTimeout("submitForm()",20000);//Expire after 20 Sec
}
function submitForm(){
document.myForm.submit();
}
</SCRIPT>
</HEAD>
<BODY onload="setTimeForSubmit()">
<FORM name="myForm" method="post" action = "somefile.html">
</FORM>
</BODY>
</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: http://aspose.com/file-tools
 
subject: Forcing a submit on a timeout