Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forcing a submit on a timeout

 
scott dawson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic