96turnerri
09-16-2003, 08:31 AM
here is a very basic js quiz i modified, i would like when click check answers, it says your score is 'x' out of 5, currently it says your score is 'x'
<body text="#FFFFFF" bgcolor="#000000">
<script>
function chk(){
total=0
for(i=0;i<document.f1.length;i++){
if(document.f1.elements[i].type=="radio"&&document.f1.elements[i].checked==true){
total+=document.f1.elements[i].value*1
}
}
document.getElementById("display").innerHTML="Your score is "+total
}
</script>
<form name="f1">
 The 'T' in James T. Kirk stands for?<p><input type="radio" name="r1" value="0">Thomas<input type="radio" name="r1" value="1">Tiberius<input type="radio" name="r1" value="0">Trevor</p>
<p>Michael Dorn who plays Worf was in which of the following films?</p>
<p><input type="radio" name="r2" value="0">The Wrath Of Khan<input type="radio" name="r2" value="0">The
Voyage Home<input type="radio" name="r2" value="1">The Undiscovered Country</p>
<p>Who plays Riker in The Next Generation / Deep Space Nine?</p>
<p><input type="radio" name="r3" value="1">Jonathan Frakes<input type="radio" name="r3" value="0">Brent
Spiner<input type="radio" name="r3" value="0">LeVar Burton</p>
<p>In the final episode of The Next Generation, All Good Things, what are
Picard's final words?</p>
<p><input type="radio" name="r4" value="1">And the sky's the limit<input type="radio" name="r4" value="0">Engage<input type="radio" name="r4" value="0">Shields
Up, Red Alert!</p>
<p>Which quadrant does the Bajoran wormhole in Deep Space Nine lead to?</p>
<p> <input type="radio" name="r5" value="0">Delta<input type="radio" name="r5" value="1">Gamma<input type="radio" name="r5" value="0">Beta</p>
<P>
<input type="button" value="Check" onclick="chk()"> <input type="reset" value="Reset">
<input type="button" value="Close" name="close" onClick="window.close()">
</form>
<div id="display"></div">
many thanks
Rich
<body text="#FFFFFF" bgcolor="#000000">
<script>
function chk(){
total=0
for(i=0;i<document.f1.length;i++){
if(document.f1.elements[i].type=="radio"&&document.f1.elements[i].checked==true){
total+=document.f1.elements[i].value*1
}
}
document.getElementById("display").innerHTML="Your score is "+total
}
</script>
<form name="f1">
 The 'T' in James T. Kirk stands for?<p><input type="radio" name="r1" value="0">Thomas<input type="radio" name="r1" value="1">Tiberius<input type="radio" name="r1" value="0">Trevor</p>
<p>Michael Dorn who plays Worf was in which of the following films?</p>
<p><input type="radio" name="r2" value="0">The Wrath Of Khan<input type="radio" name="r2" value="0">The
Voyage Home<input type="radio" name="r2" value="1">The Undiscovered Country</p>
<p>Who plays Riker in The Next Generation / Deep Space Nine?</p>
<p><input type="radio" name="r3" value="1">Jonathan Frakes<input type="radio" name="r3" value="0">Brent
Spiner<input type="radio" name="r3" value="0">LeVar Burton</p>
<p>In the final episode of The Next Generation, All Good Things, what are
Picard's final words?</p>
<p><input type="radio" name="r4" value="1">And the sky's the limit<input type="radio" name="r4" value="0">Engage<input type="radio" name="r4" value="0">Shields
Up, Red Alert!</p>
<p>Which quadrant does the Bajoran wormhole in Deep Space Nine lead to?</p>
<p> <input type="radio" name="r5" value="0">Delta<input type="radio" name="r5" value="1">Gamma<input type="radio" name="r5" value="0">Beta</p>
<P>
<input type="button" value="Check" onclick="chk()"> <input type="reset" value="Reset">
<input type="button" value="Close" name="close" onClick="window.close()">
</form>
<div id="display"></div">
many thanks
Rich