淮北語をテストする

1367 ワード

A B
A B
document.getElementById('btn').onclick = function(){ var v1, v2, res; var r1 = document.getElementsByName('num1'); var r2 = document.getElementsByName('num2'); for(var i = 0; i < r1.length; i++){ if(r1[i].checked){ v1 = r1[i].value; break; } } for(var j = 0; j < r2.length; j++){ if(r2[j].checked){ v2 = r2[j].value; break; } } res = parseInt(v1) + parseInt(v2); document.getElementById('result').innerText = ' :' + res; };