1
function circleStat(elem1, pvalue, ccolor) {
    var cx = document.getElementById(elem1);
    var percentage = 0;
    var dataval = pvalue;
}

Hi,

I am using this above mentioned code in one of my javascript projects. I would like to increase the value of percentage from 0 to datavalue (which is equal to pvalue parameter in the above mentioned function).

And from that I would like the increasing value of percentage to be updated constantly. So, I can use it in another variable of this same function. So, how to get the updated value of percentage from setInterval?

I know callback functions, but don't know how to use it on this one. Please help... Thanks in advance...

1 Answers1

0

You could make percentage and the other visible to circleStat() and then,

function circleStat() {
    updatePercentage(); // update percentage value
    // do what you need with percentage and the other
}

Now call setInterval( circleStat, someTimeInMs ).

With this you will have the updated value of percentage each time you perform what it is to be performed.

giannisl9
  • 151
  • 2
  • 11