0% found this document useful (0 votes)
77 views2 pages

Old Timer Code

timer code

Uploaded by

mishranamit2211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views2 pages

Old Timer Code

timer code

Uploaded by

mishranamit2211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<script language="javascript">

var mins
var secs;
function cd() {
mins = 1 * m("30"); // change minutes here
secs = 0 + s(":01"); // change seconds here (always add an additional se
cond to your total)
redo();
}
function m(obj) {
for(var i = 0; i < obj.length; i++) {
if(obj.substring(i, i + 1) == ":")
break;
}
return(obj.substring(0, i));
}
function s(obj) {
for(var i = 0; i < obj.length; i++) {
if(obj.substring(i, i + 1) == ":")
break;
}
return(obj.substring(i + 1, obj.length));
}
function dis(mins,secs) {
var disp;
if(mins <= 9) {
disp = " 0";
} else {
disp = " ";
}
disp += mins + ":";
if(secs <= 9) {
disp += "0" + secs;
} else {
disp += secs;
}
return(disp);
}
function redo() {
secs--;
if(secs == -1) {
secs = 59;
mins--;
}
document.cd.disp.value = dis(mins,secs); // setup additional displays he
re.
if((mins==2) && (secs==0))
alert("Submit Your Test in Time & Check the Timer");
if((mins == 0) && (secs == 0)) {
alert ("TIME'S UP");
window.open("error.htm","_top");
} else {
cd = setTimeout("redo()",1000);
}
}

function init() {
alert("method called");
cd();
}
//window.onload = init;
</script>

You might also like