Javascript - นับจำนวน Checkbox ที่ถูก Check
function checkboxAction() {
var chk1 = document.getElementById('<%=CheckBox1.ClientID%>');
var chk2 = document.getElementById('<%=CheckBox2.ClientID%>');
var chk3 = document.getElementById('<%=CheckBox3.ClientID%>');
var lab1 = document.getElementById('<%=Label1.ClientID%>');
if (chk1.checked)
a1 = 1;
else
a1 = 0; /// lab1.innerHTML = parseInt(lab1.innerHTML) + 1
if (chk2.checked)
a2 = 1;
else
a2 = 0;
if (chk3.checked)
a3 = 1;
else
a3 = 0;
lab1.innerHTML = a1 + a2 + a3;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น