In javascript we can generate a random number using Random() function. But how to generate a series of natural numbers on every refresh.
Take a range 1 to 10. First I should get 1 and then on every refresh 2, 3, 4, … should be generated. Help me
In javascript we can generate a random number using Random() function. But how to
Share
HTTP protocol is stateless, meaning on every refresh your browser/server forgets about the previous view. Thus your page on its own cannot have “memory” and remember what was the previous number.
Of course there are multiple a little bit more sophisticated solutions. E.g. you can use cookies, httpsession or maybe even some URL tricks (hash tags, query parameters). The scenario is always the same: when rendering/entering the page check the previous value and render/display the next one.