• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Forcing a submit on a timeout

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic