• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic