<body>
<div class="div_bor">
<p>这是题目</p>
<p><input type="radio" value="A" name="1"> A.选项1</p>
<p><input type="radio" value="B" name="1"> B.选项2</p>
<p><input type="radio" value="C" name="1"> C.选项3</p>
<p><input type="radio" value="D" name="1"> D.选项4</p>
<p><input type="radio" value="E" name="1"> E.选项5</p>
</div>
<div class="div_bor">
<p>这是题目</p>
<p><input type="radio" value="A" name="2"> A.选项1</p>
<p><input type="radio" value="B" name="2"> B.选项2</p>
<p><input type="radio" value="C" name="2"> C.选项3</p>
<p><input type="radio" value="D" name="2"> D.选项4</p>
<p><input type="radio" value="E" name="2"> E.选项5</p>
</div>
<p><button style="float: right" οnclick="fn()">确定</button></p>
<script>
var result = ["A","C"];
var check = [];
var score = 0;
var rule = document.getElementsByTagName("input");
function fn() {
for(var i = 0; i < rule.length; i++) {
if(rule[i].checked) {
check.push(rule[i].value);
}
}
for(var m=0,j=0;(m<result.length)&&(j<check.length); m++,j++ ){
if(result[m]== check[j]) {
score+=10;
}
}
alert(score + '分');
}
</script>
<div class="div_bor">
<p>这是题目</p>
<p><input type="radio" value="A" name="1"> A.选项1</p>
<p><input type="radio" value="B" name="1"> B.选项2</p>
<p><input type="radio" value="C" name="1"> C.选项3</p>
<p><input type="radio" value="D" name="1"> D.选项4</p>
<p><input type="radio" value="E" name="1"> E.选项5</p>
</div>
<div class="div_bor">
<p>这是题目</p>
<p><input type="radio" value="A" name="2"> A.选项1</p>
<p><input type="radio" value="B" name="2"> B.选项2</p>
<p><input type="radio" value="C" name="2"> C.选项3</p>
<p><input type="radio" value="D" name="2"> D.选项4</p>
<p><input type="radio" value="E" name="2"> E.选项5</p>
</div>
<p><button style="float: right" οnclick="fn()">确定</button></p>
<script>
var result = ["A","C"];
var check = [];
var score = 0;
var rule = document.getElementsByTagName("input");
function fn() {
for(var i = 0; i < rule.length; i++) {
if(rule[i].checked) {
check.push(rule[i].value);
}
}
for(var m=0,j=0;(m<result.length)&&(j<check.length); m++,j++ ){
if(result[m]== check[j]) {
score+=10;
}
}
alert(score + '分');
}
</script>