我有一个包含 36 个问题的表格,每个问题都有 2 个无线电输入来回答。输入命名为 i1-i36 和 j1-j36。我试图将检查过的无线电计入名为 i 的变量中,而在另一个 var 中则计入名为 j 的变量中。
试过这个,但没有奏效:
function test_it(entry) {
if (entry.value!=null && entry.value.length!=0) {
entry.value=""+ eval(entry.value);
}
computeForm(entry.form);
}
function computeForm(form) {
var rasa=0
var rasb=0
for (var count=1; count<37; count++)
{
if (form.i[count].checked){
var rasa=rasa+1;
}
}
for (var count=1; count<37; count++)
{
if (form.j[count].checked){
var rasb=rasb+1;
}
}
document.getElementById('showa').innerHTML = rasa;
document.getElementById('showb').innerHTML = rasb;
<body>
<form METHOD=POST>
Question 1
<input TYPE="radio" NAME="i1" VALUE="1">A1
<input TYPE="radio" NAME="j1" VALUE="0">A2
[...]
Question 36
<input TYPE="radio" NAME="i36" VALUE="1">A1
<input TYPE="radio" NAME="j36" VALUE="0">A2
</form>
</body>
// I want to get these:
<span id='showa'>Result a</span>
<span id='showb'>Result b</span>