On pageload I have a random number generated and saved to a variable. The problem is if I click a button within the page it generates a new random number. Once the page has loaded for the first time I want the variable to remain the same. I have tried putting the random number generation into an if else pageload statement; this has stopped it generating new random numbers when a button is clicked however it seems to then make the variable 0 if I try and call it up later. i.e -to use in a calcuation when I click another button the page.
Is there a way to generate this number only once on the first load, and for the variable to remain so anything on the page can use it, such as buttons etc..?
...
Go to the complete details ...