<script language="javascript" type="text/javascript">
var tim;
var min;
var sec;
var f = new Date();
function f1() {
min = parseInt(document.getElementById("hdnMin").value);
sec = parseInt(document.getElementById("hdnSec").value);
f2();
//document.getElementById("starttime").innerHTML = "Your Exam started at " + f.getHours() + ":" + f.getMinutes();
document.getElementById("starttime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Exam started at " + f.toLocaleTimeString() + "<img src='images/doble-quotes-02.gif' alt='' /> ";
f1 = new Date(f);
f1.setMinutes(f.getMinutes() + (parseInt(document.getElementById("hdnMin").value) + 1));
//document.getElementById("endtime").innerHTML = "Your Exam end at " + f1.getHours() + ":" + f1.getMinutes();
document.getElementById("endtime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Exam end at " + f1.toLocaleTimeString() + "<img src='images/doble-quotes-02.gif' alt='' /> ";
}
function f2() {
if (parseInt(sec) > 0) {
sec = parseInt(sec) - 1;
document.getElementById("showtime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Time Left:" + min + " Minutes ," + sec + " Seconds <img src='images/doble-quotes-02.gif' alt='' />";
tim = setTimeout("f2()", 1000);
}
else {
if (parseInt(sec) == 0) {
if (parseInt(min) == 1) {
sec = parseInt(document.getElementById("hdnSec").value);
}
if (parseInt(min) > 0) {
min = parseInt(min) - 1;
}
else {
min = 0;
}
if (parseInt(min) == 0 && parseInt(sec) == 0) {
clearTimeout(tim);
location.href = "WebForm1.aspx";
}
else {
sec = parseInt(document.getElementById("hdnSec").value);
document.getElementById("showtime").innerHTML = "Time Left:" + min + " Minutes ," + sec + " Seconds";
tim = setTimeout("f2()", 1000);
}
}
}
}
</script>
</head>
_________________________________________________________________________________
<body onload="javascript:f1();">
<table cellpadding="0" cellspacing="0" border="0" width="1100px">
<tr class="title">
<td align="left">
<div id="starttime">
</div>
</td>
<td align="left">
<div id="endtime">
</div>
</td>
<td align="left">
<div id="showtime">
</div>
</td>
<td align="right" style="width: 270px; max-width: 270px">
<asp:Label ID="lblDisplayName" CssClass="title3" runat="server"></asp:Label>
</td>
</tr>
</table>
</body>
No comments:
Post a Comment