rendered paste body<html>
<!-- this is an HTML comment and will not be evaluated by the browser
you can have many lines in a comment
Javascript and CSS use different forms for comments
-->
<head>
<title>In class 3/14/2007</title>
<script type="text/javascript">
var P1Points = 0;
var P2Points = 0;
function P1Roll(){
if (P1Points > 0 && P2Points > 0){
Susan.msg.value = ('Both Players have rolled, please click the "Next Game" button')
}
else{
if (P1Points == 0){
randomPic1(document.pic1);
randomPic1(document.pic2);
randomPic1(document.pic3);
randomPic1(document.pic4);
randomPic1(document.pic5);
randomPic1(document.pic6);
Susan.P1Points.value = P1Points;
if (P1Points > 0 && P2Points > 0){
if (P1Points > P2Points){
Susan.msg.value = ('P1 Wins')
}
if (P2Points > P1Points){
Susan.msg.value = ('P2 Wins')
}
if (P1Points == P2Points){
Susan.msg.value = ('Its a tie')
}
}
}
else{
Susan.msg.value = ("It is player 2's turn")
}
}
}
function P2Roll(){
if (P1Points > 0 && P2Points > 0){
Susan.msg.value = ('Both Players have rolled, please click the "Next Game" button')
}
else{
if (P2Points == 0){
randomPic2(document.pic1);
randomPic2(document.pic2);
randomPic2(document.pic3);
randomPic2(document.pic4);
randomPic2(document.pic5);
randomPic2(document.pic6);
Susan.P2Points.value = P2Points;
if (P1Points > 0 && P2Points > 0){
if (P1Points > P2Points){
Susan.msg.value = ('P1 Wins')
}
if (P2Points > P1Points){
Susan.msg.value = ('P2 Wins')
}
if (P1Points == P2Points){
Susan.msg.value = ('Its a tie')
}
}
}
else{
Susan.msg.value = ("It is player 1's turn")
}
}
}
function randomPic1(somePic){
var picNum = myRand()
P1Points = P1Points + picNum;
somePic.src = "images/die" + picNum + ".png";
}
function randomPic2(somePic){
var picNum = myRand()
P2Points = P2Points + picNum;
somePic.src = "images/die" + picNum + ".png";
}
function myRand(){
var rand = Math.random();
rand = Math.floor(rand * 6.0) + 1.0;
return rand;
}
function NextGame(){
P1Points = 0;
P2Points = 0;
Susan.msg.value = "";
Susan.P1Points.value= 0;
Susan.P2Points.value= 0;
}
</script>
</head>
<body bgcolor="yellow">
<table border="1">
<tr>
<td><img src="images/die0.png" width="60" height="60" name="pic1"/></td>
<td><img src="images/die0.png" width="60" height="60" name="pic2"/></td>
<td><img src="images/die0.png" width="60" height="60" name="pic3"/></td>
</tr>
<tr>
<td><img src="images/die0.png" width="60" height="60" name="pic4"/></td>
<td><img src="images/die0.png" width="60" height="60" name="pic5"/></td>
<td><img src="images/die0.png" width="60" height="60" name="pic6"/></td>
</tr>
</table>
<form name="Susan">
<input type="text" name="P1Points" value="0" />
<input type="text" name="P2Points" value="0" />
<br>
<textarea name="msg"></textarea>
<br>
<input type="button" onClick="P1Roll();" value="Player 1 Roll" name="P1Button"/>
<input type="button" onClick="P2Roll();" value="Player 2 Roll" name="P2Button"/>
<input type="button" onClick="NextGame();" value="Next Game" name="NextGame"/>
</form>
</body>
</html>