Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

trying to get countdown timer to add a forloop for another counter once it reaches zero and display it

trying to get my countdown timer when it reaches zero to add a counter with a max of 100 increments to show in a span a tag, and reset that counter once it reaches 100 back to 1. i have tried several ways and options enter code here

    function getTimeRemaining(endtime) {
    var t = Date.parse(endtime) - Date.parse(new Date());
    var seconds = Math.floor((t / 1000) % 60);
    var minutes = Math.floor((t / 1000 / 60) % 60);

    return {
    'total': t,
    'minutes': minutes,
    'seconds': seconds,
    };
    }

    function initializeClock(id, endtime) {
    var clock = document.getElementById(id);
    var minutesSpan = clock.querySelector('.minutes');
    var secondsSpan = clock.querySelector('.seconds');


    function updateClock() {
    var t = getTimeRemaining(endtime);

    minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
    secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);

    if (t.total <= 0) {
      clearInterval(timeinterval);
    }

    if(t.minutes == 0 && t.seconds ==0) {
      //  console.log('in this func');

        deadline = new Date(deadline.getTime() + 3*60000);
       initializeClock('clockdiv', deadline);



    }
    }

    updateClock();
    var timeinterval = setInterval(updateClock, 1000);
    }

    var deadline = new Date(Date.parse(new Date()) + 1 * 1 * 1 * 6 * 1000);
    initializeClock('clockdiv', deadline);

Comments