I am trying to manipulate a series of check-boxes on button click but I can't seem to figure out how to do it. I need to achieve the following actions:
Select all checkboxes
Select checkboxes 1-12
Select odd checkboxes
Select even checkboxes
Clear checkboxes
Control slider range to select weeks
All while updating the checkbox.
Here is my jsFiddle: http://jsfiddle.net/dYsg7/
Initially I was using the following code to satisfy points 1-5 but as I've changed the layout of my checkboxes I can't figure out how to implement it into my new design:
$('#week_none').click(function () {
$('#week_boxesForm li').each(function (index) {
$(this).find('input:checkbox').prop("checked", false);
});
});
$('#week_all').click(function () {
$('#week_boxesForm li').each(function (index) {
$(this).find('input:checkbox').prop("checked", true);
});
});
$('#week_term').click(function () {
$('#week_boxesForm li').each(function (index) {
if (index < 12) $(this).find('input:checkbox').prop("checked", true);
else $(this).find('input:checkbox').prop("checked", false);
});
});
$('#week_odd').click(function () {
$('#week_boxesForm li').each(function (index) {
if (index % 2 === 0) $(this).find('input:checkbox').prop("checked", true);
else $(this).find('input:checkbox').prop("checked", false);
});
});
$('#week_even').click(function () {
$('#week_boxesForm li').each(function (index) {
if (index % 2 !== 0) $(this).find('input:checkbox').prop("checked", true);
else $(this).find('input:checkbox').prop("checked", false);
});
});