Web Page Timer

Hi I am creating an online assessment system for children. Once a child is presented with a question they have 3 min to give an answer, if they do not supply an answer within the time they are automatically moved onto the next .php page. I want the timer to be visible and to be able to perform this redirect action once the 3 min is up.
Ive found a few html timers on the internet and read up on header() but they dont fully fit with what i want to do.
Does anyone have any idea of where I should be looking. Or if it is even possible?

Thanks for any help

Chris

p.s. I am brand new to php and have only started coding last week.

I believe what you looking for would use the JavaScript language. It will allow you to display a timer on the page and then redirect when the timer reaches zero.

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8" />
<title>JScript Timer</title>
</head>

<body>

<script language="JavaScript" type="text/javascript">  
var count = 180;
var redirect="http://www.phphelp.com/forum/index.php?action=post;topic=19250.0;num_replies=0"  
  
function countDown(){  
 if (count <=0){  
  window.location = redirect;  
 }else{  
  count--;  
  document.getElementById("timer").innerHTML = "You have "+count+" seconds left."  
  setTimeout("countDown()", 1000)  
 }  
}  
</script> 

<div>
    Please answer the following question... <br />
    
    Do you feel lucky?
    <br />
    Yes: <input onclick='window.location="http://www.rummagecity.com"' type="radio" name="lucky"/>
    No : <input onclick='window.location="http://www.judgd.com"' type="radio" name="lucky"/>
    <br />
</div>
    <br />
    <br />
<div id="timer">  
<script>  
 countDown();  
</script>  
</div>  

</body>
</html>

What does that do for you?

Sponsor our Newsletter | Privacy Policy | Terms of Service