Ive been searching for idea on how to get value of checkbox group but i need to the x and y for this so far what i have seen is only with one so i havent really found any relevant answer or idea to my problem so i will explain what i want to happend. In my X i have a number of columns namely first quarter,second quester,third quarter and fourth quarter in my Y i have names of students. And i also have an extra checkbox option to add additional student. I want to Check the check corresponding to names and quarter. I will used this to track down student who has taken the exam and who has not yet taken the exam. I am wondering how to group the the checkboxes in a way that when i check on it will automatically get the student name and corresponding quarter.
HTML:
<tr>
<td width="25%">
<hr/>
</td>
<td width="15%">
<center><span>1st Quarter</span>
</center>
</td>
<td width="15%">
<center><span>2nd Quarter</span>
</center>
</td>
<td width="15%">
<center><span>3rd Quarter</span>
</center>
</td>
<td width="20%">
<center><span>4th Quarter</span>
</center>
</td>
</tr>
<tr>
<td><span>Joe Smith</span>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
</tr>
<tr>
<td><span>John Smith</span>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
<td>
<center>
<input type="checkbox" name="studentrecord[]" />
</center>
</td>
</tr>
Check fiddle
Update
$("input[name='student[]']:checked").map(function() {
var $td = $(this).closest('td'),
index = $td.index();
valueToPush.push({
Quarter: quarter.eq($td.index()).find('span').text().trim(),
Student: $td.parent().find('td:first-child span').text().trim()
});
});
joe smith, I want to be able to record thatJoe Smithplus the quarter with checkJoe Smithand1 Quarter