set timer between multiple pages

Hi

I need to set a timer in a way that 20 seconds later from an event (page load) It will be redirected to a new page.
The problem is that the user maybe on the page on which I've set the timer - but most probably not.
So I need to know how to set the timer, how to pass it on (if needed),
and how to check in another page if the time runs-out.


Thanks.
arielbfAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
0
Ray PaseurCommented:
how to set the timer, how to pass it on (if needed),
What do you mean by "pass it on?"
0
Ray PaseurCommented:
Here's a teaching example showing a countdown timer.  
http://iconoun.com/demo/countdown_timer.php

<?php // demo/countdown_timer.php
error_reporting(E_ALL);

// SET THE TIMER VALUE IN THE PHP SCRIPT
date_default_timezone_set('America/Chicago');
$present = time();
$future  = strtotime('NOW + 7 SECONDS');
$timer   = $future - $present;
?>

<script type="text/javascript">
var interval = "";
var sekonds  = <?php echo $timer; ?>;

function startInterval()
{
    interval = window.setInterval("tTimer()",1000);
}

function stopInterval()
{
    window.clearInterval(interval);
    interval="";
}

function tTimer()
{
    document.thinkTime.tDisplay.value = sekonds--;
    if (sekonds == -1)
    {
        stopInterval();
    }
}
</script>

<script>
document.write('<meta http-equiv=\"Refresh\" content=\"<?php echo $timer; ?>;url=http://lmgtfy.com?q=JavaScript+Timer\">');
</script>

<form name="thinkTime">
This page will automatically search for a JavaScript Timer in
<input readonly class="timerBox" size="1" type="text" name="tDisplay" value="">
<script>startInterval();</script>
seconds.
</form>
<a href="http://lmgtfy.com?q=JavaScript+Timer">Click here if you don't want to wait.</a>

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

arielbfAuthor Commented:
I need that my users to solve some questions. They should have 20 secs in total.
So in question 1 the user starts with 20 seconds, he solve it in 5 seconds.
Now he moves to the next page (question no.2) but now he has only 15 seconds.
He solves question no.2 in 7 seconds. Now he moves to the next page (question no.3) but now he has only 8 seconds.
He cannot solve the question in 8 seconds, and the system move him on to some other page.
0
Ray PaseurCommented:
Hmm.. The WWW is not really made for that sort of thing.  Here are the issues.

1. Internet latency - you cannot know the speed of the client's connection or the route that the internet will take to send the messages.  This can vary by more than a second or two at any given moment - enough to trip up an unfortunate site visitor.
2. The nature of JavaScript is such that it is part of the HTML document.  And the WWW runs on a stateless HTTP protocol.  It is unaware of any previous JavaScript.  You might get around this with a cookie, but see #1 above.

In my opinion, this sort of thing is better suited to a single page with several questions, than to several pages with one question each.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arielbfAuthor Commented:
Well, my client needs to present the questions in different pages.

What I did until now
I used asp to see how much time the user has...
and then:

        <img src="whiteSpace.png" border="0" onload="delaySubmit()">      
       
        .... question

      
      <script language='JavaScript'>
      function delaySubmit()
      {
       setTimeout ( "submitPage()", <%=remainder*1000%> );
      }

      function submitPage()
      {
       window.location = "finalpage.asp?id="+<%=ids%>;
      }
      </script>

       But for some reason the delayed redirect is not working...
0
leakim971PluritechnicianCommented:
0
Ray PaseurCommented:
Well, my client needs to present the questions in different pages.
Sometimes a client needs a pink unicorn.  Best of luck with it! ~Ray
0
MurfurFull Stack DeveloperCommented:
Ray - I just spat out my coffee. Love it!
0
arielbfAuthor Commented:
Don't like it but must accept it....
0
Ray PaseurCommented:
Recommend deleting this question. The question contemplates a technically incompetent design. There can be no useful answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.