Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coin toss

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do I create a Web page that prompts for a number, and then throws a fair coin that number of times. Prints the results of how many heads/tails and set the background color of the Web page to say green if tails or purple otherwise.
 
do you want the visitor to see thee background changing with each toss? If so, the easiest way to do this (a for loop) cannot be used because it only updates the screen when it is finished processing. I would use:
nm=setInterval("func()",numsecs) and clearInterval(nm).
These will execute a func every numsecs seconds. You can use Math.random() to emulate the coin toss...


jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top