I am currently working on a webpage, what I need to achieve is, when I click on an icon, a message box prompt out , and there is a count down timer on the message box, when I return the count down timer, it only return the value when I trigger it, but I would like to do a live count down timer in the message box , how can I do it??
Here is the JavaScript
function phyTimer3() {
var minutes1 = Math.floor(timeleft2 / 60);
var seconds1 = Math.floor(timeleft2 % 60);
if (timeleft2 > 0) {
timeleft2 -= 1;
} else {
autoRefresh = 1;
localStorage.setItem("translateX", translate.translateX);
localStorage.setItem("translateY", translate.translateY);
localStorage.setItem("scale", scale);
localStorage.setItem("autoRefresh", autoRefresh);
localStorage.setItem("zoomLevel", zoomLevel);
window.location.reload();
}
if (seconds1 < 10) {
seconds1 = "0" + seconds1;
}
return ("Global Timer " + minutes1 + " : " + seconds1);
}
if (bs.monitoring_status == 1) {
if (bs.cooldown_duration == '') {
var timer1 = document.getElementById('timer2').value;
monitoringmsg = "Zone:" + bs.zone + " Site:" + bs.site + " Current Monitoring Status is On" +
"</br>" + "Do you want to turn it <strong>off</strong>?" + "</br>" + "Cooldown Timer : " + phyTimer3();
} else {
monitoringmsg = "Zone:" + bs.zone + " Site:" + bs.site + " Current Monitoring Status is On" +
"</br>" + "Do you want to turn it <strong>off</strong>?"
}
$("#manualSwitch").append($("<p/>").attr("id", "monitoringon").attr("title", "Monitoring Status").html(monitoringmsg));
$("#monitoringon").dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
'Yes': function() {
$("#monitoring_zone_id").val(bs.zone);
$("#monitoring_site_id").val(bs.site);
$("#actionMonitoring").val('off');
document.forms["brSwitch"].submit();
$(this).dialog('close');
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
}
The function phyTimer3
is where I return the minutes and seconds , but obviously this is not working , I am new to programming , I not sure what kind of function is working , can you guys help me on this ??