I'm very new to jquery and javascript, and I'm hoping anyone can help me find out how to count number of rows that has all their checkboxes checked.
I have a checkbox form with dynamic amount of rows and 3 checkboxes on each row. What I want to find out is how many rows that has all the 3 checkboxes checked. All the rows has id tr0, tr1, tr2 ...
This is what I have so far, it checks the first row (tr0) in my form and alerts "1" if all the boxes are checked in that row after you submit your table. When testing I have 3 tr rows + 1 header.
$(function howManyAreChecked() {
var checkedBoxes = 0;
//when the submit button under the table is clicked
$("#tabellSubmit").click(function howMany() {
var rowCount = $('#qaTabell tr').length;
//checks if row tr0 has all the boxes checked
if($("#qaTabell #tr0 input:checked").length > 2)
checkedBoxes = checkedBoxes +1;
alert(checkedBoxes);
checkedBoxes = 0;
});
});
What I need to know is how I can change the if-test to check tr0, tr1, tr2, tr3... up to tr(number of rows in the table) instead of only tr0.
Thanks in advance!