好的,所以我在javascipt中为一个测验做了这个项目,用Javascript,css,html和jquery进行了测试,并且我得到了让得分工作的问题。问题是当结果部分被加载时,在测验结束时获得总数。 1/6,每次我结束测验时,它都会提供相同的数字。这是我到目前为止有:JavaScript测验得分函数
var answers = "0";
function answerTotals()
{
if (document.getElementById("1A").checked = true) answers++;
else(console.log("answer was incorrect"));
}
这部分在页面上显示的结果:
function showScore()
{
document.getElementById("Score").innerHTML = "You Got " + answers + "/6";
console.log("Score is displayed.");
}
而问题:
<div id="questions1">
<h1>Question 1.</h1>
<br>
Why are there data types in JavaScript?
<br>
<br><input type="radio" name="q1" value="A" id="1A" onchange="question1()">As it helps a computer differentiate between different data.
<br><input type="radio" name="q1" value="B" id="1B" onchange="question1Wrong1()">There aren't.
<br><input type="radio" name="q1" value="C" id="1C" onchange="question1Wrong2()">To help it interact with Java.
<br><input type="radio" name="q1" value="D" id="1D" onchange="question1Wrong3()">To allow it to complete a task.
<br>
<input type="button" value="Next" onclick="nextQuestion();answerTotals()">
<br>
<br>
<p onclick="hint1()">
</div>
希望它不是Javascript测验! (轻松,没有实际意思) – tigertrussell 2014-12-18 23:43:26