/**
* @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.
Statement: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