Jump to content

Generating random numbers


NomenNescio
 Share

Recommended Posts

<html><head><script type="text/javascript">function disp_prompt(){times=prompt("How many numbers?","0")var numbers = "";while(times > 0){var x = Math.round(9*Math.random());numbers = numbers + x;times--;}document.write(numbers);	}</script></head><body><input type="button" onclick="disp_prompt()" value="Display a prompt box" /></body></html>

I created this code, After I enter the amount of numbers I want to be generated it gets stuck.I'm wondering why. Thank you for your time.

Link to comment
Share on other sites

<html><head><script type="text/javascript">function disp_prompt(){times=prompt("How many numbers?","0")var numbers = "";while(times > 0){var x = Math.round(9*Math.random());numbers = numbers + x;times--;}document.getElementById("random").innerHTML=numbers;	}</script></head><body><input type="button" onclick="disp_prompt()" value="Display a prompt box" /><p id="random"></p></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...