Can anyone tell me what is wrong with this script it's tearing my hair out. As you can probably guess by the code I'm a beginner.
All help appreciated.
Cheers
Paul
<html>
<head>
<script>
<!--
var numCorrect=0;
function takeTest() {
var response="";
var points=0;
var q1 = "What is the price of the Teak Elephants?";
var a1 = "$55.00";
var q2 = From what type of wood is the lion carved?";
var a2 = "EBONY";
var q3 = "What is the last name of both carvers on this page?";
var a3 = "MANE";
response = prompt(q1,"$0.00");
if (response) points=runningTotal ((response==a1) ? 1 : 0);
alert(points);
response = prompt(q2,"");
if (response) points=runningTotal ((response.toUpperCase()==a2) ? 1 : 0);
alert(points);
response = prompt(q3,"");
if (response) points=runningTotal((response.toUpperCase()==a3) ? 1 : 0);
alert("You answered a total of " + points + " correctly.");
numCorrect = 0;
points = 0;
}
function runningTotal(i) {
numCorrect += i;
return numCorrect;
}
//-->
</script>
</head>
<form>
<input type="button" class="button" value="Quiz" onClick="takeTest();">
</form>
</body>
</html>
All help appreciated.
Cheers
Paul
<html>
<head>
<script>
<!--
var numCorrect=0;
function takeTest() {
var response="";
var points=0;
var q1 = "What is the price of the Teak Elephants?";
var a1 = "$55.00";
var q2 = From what type of wood is the lion carved?";
var a2 = "EBONY";
var q3 = "What is the last name of both carvers on this page?";
var a3 = "MANE";
response = prompt(q1,"$0.00");
if (response) points=runningTotal ((response==a1) ? 1 : 0);
alert(points);
response = prompt(q2,"");
if (response) points=runningTotal ((response.toUpperCase()==a2) ? 1 : 0);
alert(points);
response = prompt(q3,"");
if (response) points=runningTotal((response.toUpperCase()==a3) ? 1 : 0);
alert("You answered a total of " + points + " correctly.");
numCorrect = 0;
points = 0;
}
function runningTotal(i) {
numCorrect += i;
return numCorrect;
}
//-->
</script>
</head>
<form>
<input type="button" class="button" value="Quiz" onClick="takeTest();">
</form>
</body>
</html>
Comment