Solved

JSP submitting after a certain time

Posted on 2004-09-25
3
282 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…

749 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