EDIT3: I have this mostly completed now, but I'm running into an error when I try to go through it. What happens is that it evaluates every if statement, regardless of whether or not it is compared correctly. I've tried to avoid using a string to use this - but when I sub move for g,n,b to an int: it doesn't work at all.
<input type='button' class='button' value='Option 1' style="left: 100px" onclick = "choice(g);" />
<input type='button' class='button' value='Option 2' style="center" onclick = "choice(n);" />
<input type='button' class='button' value='Option 3' style="right: 100px" onclick = "choice(b);" />
There's my buttons. Here's my functions:
var g, n, b;
var KarmaScore = 0; //tracks quality of your decisions
var QuestionNumber = 1; //tracks when final question, or "Important" decisions are made.
var end = 0; //Will be the value of your decision when you make a choice.
function choice(move) {
//tracks the current question
var playermove;
playermove = move;
if (playermove == g) {
alert("Good works");
KarmaScore++;
end = 1;
}
if (playermove == n) {
if (KarmaScore>0) {
alert("N + works");
KarmaScore--;
end = 0;
} else {
alert("N - works");
KarmaScore++;
end = 0;
}
}
if (move == b) {
alert("B works");
KarmaScore--;
end = 2;
}
QuestionNumber++;
playermove = 0;
q.src = "q"+QuestionNumber+".jpg";
alert(KarmaScore)
} Help is appreciated. :)