Hello,
I have a web page with a displayed google map and every several seconds the values are updated automatically on the map. Can anybody tell me please how to place an indicator that will show how much time is left for the next update?
For the timer I have this in the java script
var tim=<%= Session["21"] %>*1000;
setInterval(function(){ initialize();}, tim);
Thanks
I tried like this, but doesn't work
function startCountdown(timeLeft) {
var interval = setInterval( countdown, tim*1000 );
update();
function countdown() {
if ( --timeLeft > 0 ) {
update();
} else {
clearInterval( interval );
update();
completed();
}
}
function update() {
hours = Math.floor( timeLeft / 3600 );
minutes = Math.floor( ( timeLeft % 3600 ) / 60 );
seconds = timeLeft % 60;
setInterval(function(){ initialize();}, tim*1000);
document.getElementById('time-left').innerHTML = '' + hours + ':' + minutes + ':' + seconds;
}
function completed() {
alert('Time Up!');
//Your Logic here
//setInterval(function(){ initialize();}, tim*1000);
}
}
...
..
...
...
Time Left
Can anybody help me please?
Loading
NelPosted Sep 26, 2014, 3:33 PM
Thanks Vithal, I tried like this
var tim1;
var seconds = 20;
function countdown() {
document.getElementById("mydiv").style.visibility = "hidden";
if (parseInt(seconds) > 0) {
seconds = parseInt(seconds) - 1;
document.getElementById("showtime").innerHTML = "Your Left Time is :" + minutes + " Minutes ," + seconds + " Seconds";
tim1 = setTimeout("countdown()", 1000);
}
else {
if (parseInt(seconds) == 0) {
minutes = parseInt(minutes) - 1;
if (parseInt(seconds) == 0) {
clearTimeout(tim);
document.getElementById("showtime").style.visibility = "hidden";
document.getElementById("mydiv").style.visibility = "visible";
//location.href = "My.aspx";
}
else {
seconds = 60;
document.getElementById("showtime").innerHTML = "Your Left Time is :" + minutes + " Minutes ," + seconds + " Seconds";
tim1 = setTimeout("countdown()", 1000);
}
}
}
}
Which is embedded in the initialize() function and then I have
This map shows the intersections and the VDF coresponding measures.
CountDown Start
Time Up!
<%--
But it showed me only Countdown and Time out without showing the time at all
Vithal WadjePosted Sep 24, 2014, 11:00 AM
http://www.c-sharpcorner.com/UploadFile/f50501/countdown-timer-in-javascript/