java script:
function rps(player); {
computer=Math.round((Math.random()*2) + 1);
var cchoice;
if (computer==1) {
cchoice = "rock";
}
if (computer==2) {
cchoice = "paper";
}
if (computer==3) {
cchoice = "scissors";
}
var pchoice;
if (player==1) {
pchoice = "rock";
}
if (player==2) {
pchoice = "paper";
}
if (player==3) {
pchoice = "scissors";
}
if (choice=="rock" && cchoice=="rock"); {
alert("You have tied with the mighty computer.");
}
if (choice=="rock" && cchoice=="paper"); {
alert("The computer has covered your rock, and therefore destroyed you.");
}
if (choice=="rock" && cchoice=="scissors"); {
alert("You have destroyed the mighty computer's scissors!");
}
if (choice=="paper" && cchoice=="rock"); {
alert("You destroyed the computer's rock with your paper.");
}
if (choice=="paper" && cchoice=="paper"); {
alert("You have tied with the all mighty computer.");
}
if (choice=="paper" && cchoice=="scissors"); {
alert("The computer has cut your paper into many pieces, you lose.");
}
if (choice=="scissors" && cchoice=="rock"); {
alert("The computer has smashed your scissors with his rock.");
}
if (choice=="scissors" && cchoice=="paper"); {
alert("You have destroyed the computer with your might paper cutter.");
}
if (choice=="scissors" && cchoice=="scissors"); {
alert("You have tied with the mighty computer.");
}
}
html segment:
<script src="play.js"></script> Choose your weapon wisely!<br><br> <form> <input type="button" value="Rock" onclick="rps(1)"> <input type="button" value="Paper" onclick="rps(2)"> <input type="button" value="Scissors" onclick="rps(3)"> </form>
When I hit the buttons nothing happens, I can't figure out where I went wrong... Sorry if this is an awful attempt, I just started learning.
This post has been edited by fashionnugget: 07 December 2008 - 09:21 AM

New Topic/Question
Reply


MultiQuote





|