I am using the following script (simplified with most of the html taken out).
If someone is to press the "Check Score" button more than 5 times the value in the SCORE text form object is reset to 0. Obviously this is just a sample test and the real test is actually 15 questions. If someone goes through the test and even gets 15/15 correct they still get '0'.
I am thinking that by having onClick=Q2.value="" it is somehow wiping out the memory?
If so, is there another way to set a variable - other than onclick - that can be used with this scorequiz() function?
____
If someone is to press the "Check Score" button more than 5 times the value in the SCORE text form object is reset to 0. Obviously this is just a sample test and the real test is actually 15 questions. If someone goes through the test and even gets 15/15 correct they still get '0'.
I am thinking that by having onClick=Q2.value="" it is somehow wiping out the memory?
If so, is there another way to set a variable - other than onclick - that can be used with this scorequiz() function?
____
Code:
<head>
<script language="javascript">
<!-- Begin
function scorequiz(form) {
tally=0
if(form.Q1.value!=null && form.Q1.value=="*") {tally=tally+1}
if(form.Q2.value!=null && form.Q2.value=="*") {tally=tally+1}
form.SCORE.value =eval(tally);
}
}
</script>
</head>
_______________________
<body>
<p> 2. A Cat has how many legs?
<input type="radio" name="Q1" VALUE=" * 4" onClick=Q2.value="*">
<input type="radio" name="Q1" VALUE="1" onClick=Q2.value="B">
<input type="radio" name="Q1" VALUE="8" onClick=Q2.value="C">
<input type="radio" name="Q1" VALUE="6" onClick=Q2.value="D">
Birds have:
<input type="radio" name="Q2" VALUE=" * Wings" onClick=Q3.value="*">
<input type="radio" name="Q2" VALUE="Horns" onClick=Q3.value="B">
<input type="radio" name="Q2" VALUE="Flippers" onClick=Q3.value="C">
<input type="radio" name="Q2" VALUE="Nippers" onClick=Q3.value="D">
<INPUT NAME="SCORE" TYPE="text" maxlength="2" size="5" READONLY>
<input type="button" value="Score Quiz" onClick=scorequiz(this.form) name="button">
[/code