Riboflavin
02-26-2005, 12:42 AM
I am very new to JS and I was just playing around trying to make a random number generator.
I was using for() to make it be 10 digits long and it works when I had it in the <script> tags alone but when I tried to make it a function actvated by the button it seemed to only come out with 1 digit.
Thanks in Advance for the help,
Ribo
<html>
<head>
<title>JAVAWHAT?</title>
<script>
function rand()
{
for (count = 0; count<10; count++)
document.write(Math.round(Math.random()*10))
}
</script>
</head>
<body>
<br>
<input type="button" value="Generate" onClick = "rand()">
</body>
</html>
I was using for() to make it be 10 digits long and it works when I had it in the <script> tags alone but when I tried to make it a function actvated by the button it seemed to only come out with 1 digit.
Thanks in Advance for the help,
Ribo
<html>
<head>
<title>JAVAWHAT?</title>
<script>
function rand()
{
for (count = 0; count<10; count++)
document.write(Math.round(Math.random()*10))
}
</script>
</head>
<body>
<br>
<input type="button" value="Generate" onClick = "rand()">
</body>
</html>