Hi experts,
I have a simple single line of text field called new_timer that runs an active stopwatch using the javascript code below:
//Initialize time attributes
var seconds = 0, minutes = 0, hours = 0,t;
function add() {
seconds++;
if (seconds >= 60) {
seconds = 0;
minutes++;
if (minutes >= 60) {
minutes = 0;
hours++;
}
}
//creating time value in hh:mm:ss formate
var tmp = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
Xrm.Page.getAttribute("new_timer").setValue(tmp);
//recursively calling timer
timer();
}
//main timer method
function timer() {
t = setTimeout(add, 1000);
}
function pause()
{
clearTimeout(t);
}
function resume()
{
clearInterval(t);
timer();
}
I have added 2 buttons to call pause and resume function on my form ribbon.
How can I add functionality where if the timer is active, show only the pause button and if the timer is paused, only show the resume button?
Thanks,
Jon









