At the first glance I thought you were experiencing issues created by the
var
in JavaScript and was going to suggest the usage of
let
. :laugh:
But after reading the question complete, I came to know that perhaps you need to do this,
for(var i = 1; i <= count; i++) {
alert(i);
}
And that also answers the problem you are facing,
Quote:
In count i am getting 100th record
That is because count is set to be 100 (
in your code behind).
Also, you are not even accessing any element from anywhere—
collection[i]
—so how can you say that you are getting 100th? Did you mean to say, you get 100 always?
Please see the following links,
scope - What's the difference between using "let" and "var" to declare a variable in JavaScript? - Stack Overflow[
^]
let | MDN[
^]
for | MDN[
^]
You can also try to explore the loop in this online fiddle that I created,
Edit fiddle - JSFiddle[
^]