I am making a web online test and there is a time calculate using javascript. When I add the scriptmanager why the timer does not work. Usability of scriptmanager so that update panel can be used. Please help me. Urgent.
<head runat="server">
<title></title>
<script type="text/javascript">
var mins
var secs;
function cd() {
mins = 30 * m("1");
secs = 0 + s(":01");
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);
if ((mins == 0) && (secs == 0)) {
window.alert("Waktu telah habis. Tekan OK untuk lanjut.");
window.open("module.aspx", "_parent ")
} else {
cd = setTimeout("redo()", 1000);
}
}
function init() {
cd();
}
window.onload = init; </script>
<style>
#txt
{
border: none;
font-family: verdana;
font-size: 16pt;
font-weight: bold;
border-right-color: #FFFFFF;
}
</style>
</head>
<body>
<form name="cd" runat="server">
<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<center>
<div style="margin-left: 190px">
<input id="txt" readonly="true" type="text" value="30:00" border="0" name="disp"></div>
</center>
</form>
</body>
</html>