aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Submitting a JSP page after a predefined Time limit 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 "Submitting a JSP page after a predefined Time limit" Watch "Submitting a JSP page after a predefined Time limit" New topic
Author

Submitting a JSP page after a predefined Time limit

Anshul Mathur
Greenhorn

Joined: Nov 07, 2003
Posts: 22
Hello All

I am making an online QUIZ for my College and want to include the feature that page automatically submits to a servlet/JSP after the time limit is exhausted.

Thanks

Anshul Mathur
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
This is one of the examples in my book that I am writing.

You need to use a setTimeout() method, basic idea

onload="setTimeout('document.formName.submit()',numMilliseconds)";

Eric
Gaurav Jain
Ranch Hand

Joined: Mar 11, 2004
Posts: 108
You can use the setTimeout() function of javascript.
Call the submit function from setTimeout and the page will b submitted after the predefined time limit.

setTimeout('yourFunction()',3000)
3000 is time in millisecinds.
Call the setTimeout function based on your condition/requirement.
Anshul Mathur
Greenhorn

Joined: Nov 07, 2003
Posts: 22
Thanks a lot.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Keep in mind , that if user have access to address bar he could change that time thing.
For Erics example

If I type in address bar:

the page will be submited only after I type in address bar
Saumyaraj Zala
Ranch Hand

Joined: Aug 06, 2012
Posts: 56

I have a similar problem.
A user can finish quiz by clicking submit button or it will be submitted after a predefined time out.
Where to call the javascript method ontimeout?


Why do we fall? So that we can learn to pick ourselves up.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Attach it to the window load event.

 
jQuery in Action, 2nd edition
 
subject: Submitting a JSP page after a predefined Time limit