Engagosoods
New Member
I am creating a basic modified Crapps game. I am using java script and HTML. So It will not look great, but its purpose is to teach me Java Script. I am still in the beginning stages and have hit a road block. What is supposed to happen is when I click a button this function happens. My function occurs yet it keep rolling 2 6's and thus the dice show up as 6. Everything works except that the 6 keeps reoccurring. I went through code and could not find common mistakes- making sure the numbers it should generate is covered, that my bases are covered 6 numbers (1-5) all have a job, my names are correct, etc. I know my function is being called because the image of the dice shows up as 6 every time where I want it to go.\[code\] function rolldice() { dice1=Math.floor(Math.random()*6+0); if(dice1=0) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/1.jpg' width='100' height='100' />"; } if(dice1=1) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/2.jpg' width='100' height='100' />"; } if(dice1=2) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/3.jpg' width='100' height='100' />"; } if(dice1=3) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/4.jpg' width='100' height='100' />"; } if(dice1=4) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/5.jpg' width='100' height='100' />"; } if(dice1=5) { document.getElementById("dice1").innerHTML="<img src='http://stackoverflow.com/questions/14544370/6.jpg' width='100' height='100' />"; }dice2=Math.floor(Math.random()*6+0); if(dice2=0) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/1.jpg' width='100' height='100' />"; } if(dice2=1) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/2.jpg' width='100' height='100' />"; } if(dice2=2) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/3.jpg' width='100' height='100' />"; } if(dice2=3) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/4.jpg' width='100' height='100' />"; } if(dice2=4) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/5.jpg' width='100' height='100' />"; } if(dice2=5) { document.getElementById("dice2").innerHTML="<img src='http://stackoverflow.com/questions/14544370/6.jpg' width='100' height='100' />"; } }\[/code\]