Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSP submitting after a certain time

Posted on 2004-09-25
3
Medium Priority
?
286 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 240 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Ranking ecommerce websites is a vital process. You need to have a strong SEO (Search Engine Optimization) strategy. If you don’t have one, you are losing out on brand impressions, clicks and sales. Check this guide on how to improve website traffic …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

876 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