Link to home
Start Free TrialLog in
Avatar of Rik Van Lier
Rik Van LierFlag for Belgium

asked on

scripting lottery

hi,

i am stuck with a question from a customer!

my customer wants a webpage with a button that show a random number between 0 and 4000.

but the script need to generate that numer one by one. so first click the first number, then the second number, then the thirth and then the last number.

and the total number cannot be higher then 4000.

can anyone build this for me? i need a html of php page that can do this?
Avatar of David Favor
David Favor
Flag of United States of America image

Sounds like you can just repeatedly call random with a ceiling of 4000, keeping track of all numbers returned for one session.

If a duplicate number comes back, just call random again.

Just keep a hash of numbers returned so far in one session, so you can do fast lookups + if you ever require expanding total numbers returned, all your de-dup (duplicating) code will just continue to work, as-is.
Avatar of Flabio Gates
Flabio Gates

no PHP, just javascript and JQuery: fiddle
note warning re infinite loop
ASKER CERTIFIED SOLUTION
Avatar of Flabio Gates
Flabio Gates

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Question inactive