Hi Oyster,
Sorry I have'nt time to sort your code right now but here is a full quiz I wrote a while back for a friend. It's easy to follow and you can easily edit it to suit.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Oysters Quiz</title>
<script type="text/JavaScript">
<!--
var ans = new Array;
var done = new Array;
var yourAns = new Array;
var explainAnswer = new Array;
var score = 0;
// correct answers - just change these
ans[1] = "b";
ans[2] = "b";
ans[3] = "a";
ans[4] = "c";
ans[5] = "b";
// reasons for the answers - just fill them in
explainAnswer[1]="The reason why Answer 1 is -b- is because Blah Blah Blah";
explainAnswer[2]="The reason why Answer 2 is -b- is because Blah Blah Blah";
explainAnswer[3]="The reason why Answer 3 is -a- is because Blah Blah Blah";
explainAnswer[4]="The reason why Answer 4 is -c- is because Blah Blah Blah";
explainAnswer[5]="The reason why Answer 5 is -b- isbecause Blah Blah Blah";
function do_answers_stuff(question, answer) {
yourAns[question]=answer;
}
function Score(){
var answerText = "How did you do?\n------------------------------------\n";
for(i=1;i<=5;i++){
answerText=answerText+"\nQuestion :"+i+"\n";
if(ans[i]!=yourAns[i]){
answerText=answerText+"\nThe correct answer was "+ans[i]+"\n"+explainAnswer[i]+"\n";
}
else{
answerText=answerText+" \nCorrect! \n";
score++;
}
}
answerText=answerText+"\n\nYour total score is : "+score+"\n";
//now score the user
answerText=answerText+"\nComment : ";
if(score<=0){
answerText=answerText+"You need to get out more often";
}
if(score>=1 && score <=2){
answerText=answerText+"bit more practice and you'll do OK.";
}
if(score>=3 && score <=3){
answerText=answerText+"Hmmm. alright but hmmmmmm";
}
if(score>4){
answerText=answerText+"You need to go back to high school!!!";
}
alert(answerText);
}
//-->
</script>
</head>
<body>
<div align="center">
<h1>Oysters Quiz</h1>
<b>Prepare to be questioned like you've never been questioned before!!</b>
<hr>
<FORM>
<b>1. People who don't know you tend to think you are?</b><br>
<input type=radio name="q1" value="a" onClick="do_answers_stuff(1, this.value)">a) Awful<br>
<input type=radio name="q1" value="b" onClick="do_answers_stuff(1, this.value)">b) Horrible<br>
<input type=radio name="q1" value="c" onClick="do_answers_stuff(1, this.value)">c) Prude.<br>
<input type=radio name="q1" value="d" onClick="do_answers_stuff(1, this.value)">d) Beautiful.<br>
<input type=radio name="q1" value="d" onClick="do_answers_stuff(1, this.value)">d) Ugly.<p>
<b>2. Please pick an item.</b><br>
<input type=radio name="q2" value="a" onClick="do_answers_stuff(2, this.value)">a) Your nose<br>
<input type=radio name="q2" value="b" onClick="do_answers_stuff(2, this.value)">b) Your toes<br>
<input type=radio name="q2" value="c" onClick="do_answers_stuff(2, this.value)">c) Your spots<br>
<input type=radio name="q2" value="d" onClick="do_answers_stuff(2, this.value)">d) A nice chocolate/candy bar<p>
<b>3. What music do you listen to?</b><br>
<input type=radio name="q3" value="a" onClick="do_answers_stuff(3, this.value)">a) Crap - er sorry, I meant Rap<br>
<input type=radio name="q3" value="b" onClick="do_answers_stuff(3, this.value)">b) Soothing music<br>
<input type=radio name="q3" value="c" onClick="do_answers_stuff(3, this.value)">c) Punk<br>
<input type=radio name="q3" value="d" onClick="do_answers_stuff(3, this.value)">d) Heavy metal <p>
<b>4. When you look in your room, what do you see?</b><br>
<input type=radio name="q4" value="a" onClick="do_answers_stuff(4, this.value)">Dirty socks<br>
<input type=radio name="q4" value="b" onClick="do_answers_stuff(4, this.value)">Little 'orrible brother<br>
<input type=radio name="q4" value="c" onClick="do_answers_stuff(4, this.value)">Cobwebs 'n spiders<br>
<input type=radio name="q4" value="d" onClick="do_answers_stuff(4, this.value)">Clothing all over the place<p>
<b>5. Okay, you're sick of life. What do you do?</b><br>
<input type=radio name="q5" value="a" onClick="do_answers_stuff(5, this.value)">Listen to music to die by such as as 'Everybody Hurts - REM'<br>
<input type=radio name="q5" value="b" onClick="do_answers_stuff(5, this.value)">A deal with the Devil<br>
<input type=radio name="q5" value="c" onClick="do_answers_stuff(5, this.value)">Shout 'I love George Bush' outside 10 Downing Street,UK<br>
<input type=radio name="q5" value="d" onClick="do_answers_stuff(5, this.value)">Shout 'I love Tony Blair' outside the the Whitehouse,USA<p>
</center>
<center>
<input type=button onClick="Score()" value="Well... How did I do?">
</center>
</form>
</div>
</body>
</html>
Hope this helps for now - have fun!!
Regards,
Ges.
Bookmarks