TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pawan Kumar Tiwari
NA
87
3k
Resume Javascript Timer from database value
Jun 26 2017 4:30 AM
I want to resume the timer from the last saved value in database in my online test series portal. Format of storing time is in "hh:mm:ss". Timer has been implemented using javascript. I am storing the last time to a session and assigning it to a label based on condition. If the session is found to be null, the default time is taken for the corresponding paper. How do I resume the timer for the last saved time for a paper which is resumed ? I am attaching my javascript code of timer :
<script type="text/javascript">
var myVar = setInterval(function () { myTimer() }, 1000);
var d = new Date();
var starttime = document.getElementById("<%= lbl_total_time.ClientID %>").innerHTML;
if (parseInt(starttime) < 10) {
starttime = "0" + starttime;
}
else {
starttime = starttime;
}
d.setHours(00, (parseInt(starttime) - 1), 59, 00);
function myTimer() {
if (d.getSeconds() <= 1)
d.setMinutes(d.getMinutes() - 1, 59, 00);
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds() - 1;
if (h == 0 && m == 0 && s == 1) {
document.getElementById("<%= lbsendintime.ClientID %>").innerHTML = "00:00:00";
}
else {
if (h < 10) {
h = "0" + h;
}
if (m < 10) {
m = "0" + m;
}
if (s < 10) {
s = "0" + s;
}
document.getElementById("<%= lbsendintime.ClientID %>").innerHTML = h + ":" + m + ":" + s;
d.setMinutes(m, s);
}
}
</script>
.... Here, in the above code, field 'lbl_total_timer' is the label to which time is assigned from database. 'Thanks in advance...
Reply
Answers (
3
)
Error Handling in MVC View
Whyshouldwe use thepostback?mostly where should use and uses