Sounds like homework.
Code:
<script type = "text/javascript">
function getRoundedRandomNumber(num) {
var randy = Math.floor(Math.random() * num +1);
alert (randy);
}
</script>
<strong>A test of the random number functions <br></strong>
<input type = "button" name = "randomButton" value ="Display Random Number" onclick = "getRoundedRandomNumber(50);">
<script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead.
Use lowercase for tags - <script>, <input> etc.
Math.round() does not produce true random numbers. In this case the numbers 0 and 50 will be chosen less frequently. Other numbers in the range can be arrived at by rounding up or by rounding down - but 50 can only be arrived at by rounding up, and 0 only by rounding down. Use instead Math.floor(Math.random() * num +1). If you want another explanation see:-
http://www.shawnolson.net/a/789/make...om-useful.html
Note the difference between
var randy = Math.floor(Math.random() * num +1); // gives 1 to num
and
var randy = Math.floor(Math.random() * (num +1)) // gives 0 to num
BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.