1 Reply Latest reply on Jul 31, 2015 3:34 AM by dimitric11477153

    Number count up with decimal places

    dimitric11477153

      Hi,

       

      There are some good examples of how to count a number up in Edge however none of them can do so using 2 decimal places.

      Have no idea Can anyone please help?

        • 1. Re: Number count up with decimal places
          dimitric11477153 Level 1

          Have figured it out... Below is code for counting up as well as counting down...

           

          To count down...

           

          var delay = 10;

          var endVal = 300.75;

          var startVal = 500.93;

           

          var timer = window.setInterval(countDown,delay);

          function countDown(){

            startVal=startVal-1.12;

            startVal=Number((startVal).toFixed(2));

            sym.$("Text").html(startVal);

            if(startVal <= endVal)

            {

            sym.$("Text").html(endVal.toFixed(2));

            clearInterval(timer);

            }

          }

           

           

           

          To count up...

           

          var delay = 10;

          var endVal = 157.90;

          var startVal = 0;

           

          var timer = window.setInterval(countUp,delay);

          function countUp(){

            startVal=startVal+1.12;

            startVal=Number((startVal).toFixed(2));

            sym.$("Text").html(startVal);

            if(startVal >= endVal)

            {

            sym.$("Text").html(endVal.toFixed(2));

            clearInterval(timer);

            }

          }