Emulate PHP’s Rand() Function in Javascript

Javascript’s random number generator is lacking a lot of power. To create a number between say 0 and 10, you can do this:

number = Math.round(Math.random()*10);

Of course you can modify this slightly to fit your needs, but this should be the basics needed.

Leave a Reply






Copyright 2008 Troy Whiteley & OjaiSoft

CSS | PHP | XHTML/HTML | JavaScript | Featured Sites

Home | Labs | License | RSS | Log in