Hi!
I have a timer script. When refreshing the page or going to another page with the same script it starts from zero offcause. I want to pass the remaining time via a hidden for field and then put that in the script as the inintial value. But how?
I tried doing it with this
Code:
document.forms[0].tiden.value = countdownTimer;
or this
Code:
document.getElementById('tiden').value = countdownTimer;
I tried it with the remainingSeconds variable. Nothing is passed.
I'm collecting the form value with Response.Write("Time: " & request.Form("tiden"))
The input looks like this
Code:
<input id="tiden" name="tiden" type="hidden" value="">
and the timer script:
Code:
var seconds = 1000;
function secondPassed() {
var minutes = Math.round((seconds - 30)/60);
var remainingSeconds = seconds % 60;
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
document.getElementById('countdown').innerHTML = "Time left: " + minutes + ":" + remainingSeconds;
if (seconds == 0) {
clearInterval(countdownTimer);
document.getElementById('countdown').innerHTML = "Time is up!";
alert("You will be transfered to another page");
window.location = "http://www.google.com"
} else {
seconds--;
}
}
var countdownTimer = setInterval('secondPassed()', 1000);