Lottery number picking program

I decided to write a  small program using jQuery/CSS. This is similar to my other programs, in that js plays a major part in the structure. The program is a lottery number picker that uses a gif in the background to simulate a rolling cylinder and I use jQuery to animate some ball gifs to look like their bouncing around;. I used gimp for the gifs.

The code I used for the random numbers uses the (Math. random) function with min and max vars to keep it inside of 0 and 74. For the power ball I use the same function for 1-15. The algorithm I used for the five random numbers involved creating an array 01-75, generating the random numbers and getting the value of the array in that array place. This means the random number was used like array[a] so that the number in that place was one of the five random numbers based on a random number. Just generating a random number seemed like a shortcut so I took the long way around. Although, I could have really complicated things by mixing the original array around first and then grabbing the numbers.

I use the ball gifs to display the five random numbers presented and the Powerball. Also, I use the ball gifs in the animation in the div that the main animated gif is in. The animation routine is a simple jQuery and CSS code structure that randomly moves the balls around inside the containing div and I used the animated gif as the div background.

I guess the hardest part, if there was one, would be the check on making sure I didn't get any duplicates in final number selections. For this I just looped over a comparison array while creating the final array. The end result is a fairly quick lottery number picker in a clean interface.

To take a look click here.

by Jim Atkins 'thedosmann'

Memphis Web Programming