leonaapple
New Member
I want it to display dice image but no output? What's wrong? I choose a random number from 1-6 and it will show the face of the dice. Well it is supposed to but it's not working. I also want to display the images elsewhere not replacing the button. How do you do that?\[code\]<html><head><title>DiceBoy</title></head><body><script>function getRandom(){var RandomNumber1 = Math.floor(Math.random() * 6) + 1;var RandomNumber2 = Math.floor(Math.random() * 6) + 1; if(RandomNumber1 == 1) document.write('<img src="http://stackoverflow.com/questions/14623091/dice1.png">'); else if(RandomNumber1 == 2) document.write('<img src="http://stackoverflow.com/questions/14623091/dice2.png">'); else if(RandomNumber1 == 3) document.write('<img src="http://stackoverflow.com/questions/14623091/dice3.png">'); else if(RandomNumber1 == 4) document.write('<img src="http://stackoverflow.com/questions/14623091/dice4.png">'); else if(RandomNumber1 == 5) document.write('<img src="http://stackoverflow.com/questions/14623091/dice5.png">'); else var document.write('<img src="http://stackoverflow.com/questions/14623091/dice6.png">');}</script><input type="button" value="http://stackoverflow.com/questions/14623091/Throw Dices" onClick="getRandom();">\[/code\]