I want a small javascript code to generate a random numbers based on some inputs, and show these numbers on a webpage so that it looks like the number is changing. Basically, these numbers are the value of a jackpot on my website. I want the jackpot value to be increasing so that as the user looks at it, the jackpot increases randomly.
What I want to do is give a starting value to the javascript (eg. 100.30) and and then a series of values to randomly add to the value every X seconds.
E.G.
Starting value: 100.30
Random values: 0.01, 0.02, 0.03
Seconds: 5
In the example above, the javascript would choose one of the 3 values between 0.01 and 0.03 every 5 seconds, and add it to the starting value of 100.30, so that the variable could increase like:
100.30, 100.31, 100.34, 100.37, 100.38, 100.40... and so on.
Note, that some of the random values I specify could be negative or 0.
What I also want is a maximum value so that once the variable hits a certain value, it resets back to the starting value. For example, let's say the maximum value is 100.40, then the next value in the series above would be 100.30 because it resets.
Each random value to add should be given equal weighting, so by including the value 0.01 twice, for instance, it should on average appear twice.
I was hoping to use normal text for the changing variable, but I understand from chatting to coders that I may have to use an textbox in a form so that the variable can change?
Thanks in advance,
David Hammond
## Deliverables
As above. Plus, a html page with the javascript in action!
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Javascript
HTML output