javascript制作在线试题的问题(求助)
做一份试题,做完后提交显示出新的页面,得到分数和错误试题的答案,但时我提交了以后就会出现空白页,试了很久都没解决,问题好像出在calculateScore的函数里,但不知道怎么错了,哪位大哥帮忙看看,小弟不胜感激,代码如下:<html>
<head>
<script type = "text/javascript">
var num_MC = 6;
var num_TF = 4 ;//number of question
var solution_MC = new Array(num_MC);
solution_MC[0] = "18";
solution_MC[1] = "27";
solution_MC[2] = "11";
solution_MC[3] = "1.25";
solution_MC[4] = "1.6";
solution_MC[5] = "-5";
var solution_TF = new Array(num_TF);
solution_TF[0] = "False";
solution_TF[1] = "True";
solution_TF[2] = "False";
solution_TF[3] = "False";
var marks = 0;
function CalculateScore()
{
var number;
var number1;
var result_MC = "";
var result_TF = "";
for (number=0; number < num_MC; number++)
{
if (document.MC.q1[num_MC].value == "1")
{
marks+=12;
}
else
{
result_MC += "Question "+(number+1) + ": " + solution_MC[number] + "<BR>";
}
}
for (number1=0; number1 < num_TF; number1++)
{
if (document.TF.q2[num_TF].value == "1")
{
marks+=7;
}
else
{
result_TF += "Question "+(number1+7) + ":" + solution_TF[number1] + "<BR>";
}
}
}
var ScoreWin;
function ScoreWinWindow()
{
ScoreWin = window.open("","answers","resizable=no, toolbar=no, menubar=no, status=no, location=no, scrollBars=yes");
CalculateScore();
if(marks == "100")
{
ScoreWin.document.write("<font color = 'red'> Congralation, the answers are all right!!");
}
else
{
ScoreWin.document.write("<font color='red'>Correct Answers:</font><p>" + result_MC + result_TF);
}
ScoreWin.document.write( "Your Test Result is " + marks + "/100");
}
</script>
</head>
<body>
<tr>
<td>
<form><center>Online Quiz - Math Test</center><p></form>
Mutiple Choice (6*12)<HR>
<form id = "MC" action = "JavaScript:CalculateScore()">
<form>
(1) 2 * 9 = ____
<br>
<input type="radio" name="q1" value="0">17
<input type="radio" name="q1" value="1">18
<input type="radio" name="q1" value="0">27
<input type="radio" name="q1" value="0">19
<br><br>
</form>
<form>
(2) 3 * 7 = ____
<br>
<input type="radio" name="q1" value="0">22
<input type="radio" name="q1" value="1">21
<input type="radio" name="q1" value="0">14
<input type="radio" name="q1" value="0">20
<br><br>
</form>
<form>
(3) 4 + 7 = ____
<br>
<input type="radio" name="q1" value="0">14
<input type="radio" name="q1" value="0">10
<input type="radio" name="q1" value="1">11
<input type="radio" name="q1" value="0">13
<br><br>
</form>
<form>
(4) 5 / 4 = ____
<br>
<input type="radio" name="q1" value="0">1
<input type="radio" name="q1" value="1">1.25
<input type="radio" name="q1" value="0">2
<input type="radio" name="q1" value="0">9
<br><br>
</form>
<form>
(5) 8 / 5 = ____
<br>
<input type="radio" name="q1" value="0">1
<input type="radio" name="q1" value="1">1.6
<input type="radio" name="q1" value="0">2
<input type="radio" name="q1" value="0">4
<br><br>
</form>
<form>
(6) 9 - 14 = ____
<br>
<input type="radio" name="q1" value="0">5
<input type="radio" name="q1" value="0">4
<input type="radio" name="q1" value="0">0
<input type="radio" name="q1" value="1">-5
<br><br>
</form>
</form>
True or False (4*7)<HR>
<form id = "TF" action = "JavaScript:CalculateScore()">
<form>
(7) 5 - 17 = 12
<br>
<input type="radio" name="q2" value="0" >True
<input type="radio" name="q2" value="1" >False
<br><br>
</form>
<form>
(8) 15 * 5 = 75
<br>
<input type="radio" name="q2" value="1" >True
<input type="radio" name="q2" value="0" >False
<br><br>
</form>
<form>
(9) 25 - 78 = 53
<br>
<input type="radio" name="q2" value="0">True
<input type="radio" name="q2" value="1">False
<br><br>
</form>
<form>
(10) 14 / 3 = 4
<br>
<input type="radio" name="q2" value="0" >True
<input type="radio" name="q2" value="1" >False
<br><br>
</form>
</form>
<form>
<div align="center">
<input type="button" name="Submit" value="Submit" onClick="ScoreWinWindow()">
</div>
</form>
</td>
</tr>
</body>
</html>