Home > Web Front-end > JS Tutorial > Javascript script programming solves the problem of test score statistics_javascript skills

Javascript script programming solves the problem of test score statistics_javascript skills

WBOY
Release: 2016-05-16 18:59:44
Original
1335 people have browsed it

Copy code The code is as follows:

/**
* @author georgewing
*/
function prepareCheckBox() {
document.getElementById("submit").onclick = function() {
selectedCheckBox(4);
}
}
function selectedCheckBox(x) {
var oInput = document.getElementsByTagName("input");
var iTotal = 0;
for(var i=0;iif(oInput[i].className == "checkedRadio") {
if(oInput[i].checked) {
//add x point
iTotal = iTotal x;
}
else {
// add 0 point
iTotal = iTotal 0;
}
}

}
document.getElementById("Total").setAttribute("value", iTotal);
alert(iTotal);
}

Tip: Abstract the constant 4 into a variable x, which is used as a parameter of the function. This is hard-coded abstraction. For details about hard-coding and abstraction, see the translation section of the "DOM scripting" book.
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template