...

View Full Version : random whole number



the_bob
12-24-2003, 01:34 AM
ok, i'm very new at javascripting and just ran into a problem. I want to have a random whole number but with this code I get a decimal. Would any of you know how to fix this?



<form>
<input type="button" value="random number" onClick="alert(Math.random()*11)">
</form>

Skyzyx
12-24-2003, 01:46 AM
<form>
<input type="button" value="random number" onclick="alert(Math.round(Math.random()*11))">
</form>

the_bob
12-24-2003, 02:08 AM
Thank you very much Skyzyx, that is exactly what I wanted.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum