Solved

JSP submitting after a certain time

Posted on 2004-09-25
3
278 Views
Last Modified: 2010-04-01
Hi Experts,

May I ask how to submit a page without clicking a button or whatsoever...   just time controlled if possible...

A sample code would be best...


Thanks in advanced experts...!    =)
0
Comment
Question by:aris_datuin
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
lhankins earned 60 total points
ID: 12150852
just use some javascript with the setTimeout function, for example, the following will cause the form to be submitted 3 seconds after the page has fully loaded (this is setup in the initUi() method which is called by the document.onload handler). :


--------------------------------------
<html>
<head>

<script type="text/javascript">

function doSubmit()
{
   alert("submitting form");
   document.forms[0].submit();
}

function initUi()
{
   setTimeout("doSubmit();", 3000);
}

</script>
</head>

<body onload="initUi()">
   <form action="/actions/doSomething">

      <input type="text" value="some value"/>
   </form>
</body>

</html>


0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12150860
The short answer...You cant.

Here are some options though..
   -You could set the page to refresh to a new URL after N seconds
   -You could setup an event handler on mousemove, keydown, etc.  and implement a timer there
    eg.  
     var pageStart=new Date()
     function onMouseMove()
     {
        var now=new Date();
        var delta=now.getTime()-pageStart.getTime()
        if (delta>60000)
           form.submit();
     }
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12150862
sorry, forgot about the setTimeout.  That would work too
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to write service layer in Spring ? 4 273
logging jar 1 105
Display the newly inserted values 3 72
excpetion with multiple catch 11 105
A Short Story about the Best File Recovery Software – Acronis True Image 2017
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now