so currently I am building a website where I get data from google spreadsheets and then graph it on my website...
However, because this data is constantly streamed from somewhere else, I need to be able to show 10 data points on the graph every time. (So shows 10 data points then the next 10 and then the next 10 and so on). So I personally need 2 global variables to keep track of where in the data I am thus be able to present the user with the correct graph.
I have tried this...
<script>
var i = 0;
var lengtharray = 0; //This variable is the second global variable that I need and is updated within the same function as i.
function doSomething(){
anotherFunction();
i = i + 10;
lengtharray++;
}
</script>
so the next time the script is run to show the next data point on the graph, the i value that I expect is the previous i value + 10 and the lengtharray value to be incremented...
instead, what I get is i = 0 again and lengtharray = 0 again..
I need these values to be "updated" and only initialised/reset when I want it to be/the browser closed and reopened on the webpage...
I hope this question all makes sense!
Thanks in advance.