return 5 min later and the timer will restart. So i were wondering if there is some kind of way to make it input the last recorded data into a
database so that the user returns 5 min later and (will have date/time function to see how long) it will begin counting but minus 5 min and
the allready passed time.
My code for timer is:
Code: Select all
var sec=59;
var timer_is_on=0;
var Reset=0;
var Min=11;
var Hour=1;
var Day=1;
function SetTime(){
if (Reset == 0){
if (sec==0 && Min==0 && Hour==0){
Hour=24;
Min=59;
sec=59;
RedoTimer();
Reset=1;
}
}
}
function timedCount(){
if (sec>=0){
if (sec<10 && Min>=10){
document.getElementById('txt').value=Day + " : " + Hour + " : " + Min + " : " + "0" + sec;
}else if (Min<10 && sec>=10){
document.getElementById('txt').value=Day + " : " + Hour + " : " + "0" + Min + " : " + sec;
}else if (Min<10 && sec<10){
document.getElementById('txt').value=Day + " : " + Hour + " : " + "0" + Min + " : " + "0" + sec;
}else{
document.getElementById('txt').value=Day + " : " + Hour + " : " + Min + " : " + sec;
}
Timer();
}
if (sec==-1 && Min>0){
MinCheck();
}
if (sec==-1 && Min==0 && Hour>0){
HourCheck();
}
if (sec==-1 && Min==0 && Hour==0 && Day>0){
DayCheck();
}
if (sec==0 && Min==0 && Hour==0){
StopCount();
}
if (Reset==1 && sec==0){
ReReset();
}
}
function Timer(){
sec=sec-1;
setTimeout("timedCount()",1000);
}
function MinCheck(){
Min=Min-1;
sec=59;
}
function HourCheck(){
Hour=Hour-1;
Min=Min-1;
Min=59;
sec=59;
}
function DayCheck(){
Day=Day-1;
Hour=Hour-1;
Min=Min-1;
Hour=1;
Min=59;
sec=59;
}
function ReReset(){
Reset=0;
}
function doTimer(){
if (Reset==0){
if (timer_is_on=1){
timedCount();
}
}
}
function RedoTimer(){
timer_is_on=1;
timedCount();
}
function stopCount(){
timer_is_on=0;
}
Code: Select all
<html>
<head>
<script type="text/javascript" src="timer.js">
</script>
</head>
<body>
<form><input type="button" value="Start Timer!" onclick="doTimer()" /> <br>
<input type="text" id="txt" /> <br>
<input type="button" value="Restart Timer!" onclick="SetTime()" /></form> <br>
</body>
</html>