I am trying to learn how to use jQuery and I stumbled upon this code and the requirements below:
- disable all the cells from "Every Monday" till "Every Sunday" as the initial status;
- make "Never" exclusive from all the rest of options in the same row;
- make "Less often", "Monthly" and "Weekly" exclusive each other;
- when "weekly" is selected, eable the cells from "Every Monday" till "Every Sunday", and you can select more than one answer;
- when "weekly" is deselected, disable the cells from "Every Monday" till "Every Sunday", and deselect all these cells.
Here is the fiddle with the code: Click Here
So far I figured how to solve the fourth requirement, but apply it for a single row..
$(function() {
enable_cb();
$("#group1").click(enable_cb);
});
function enable_cb() {
if (this.checked) {
$("input.group1").removeAttr("disabled");
} else {
$("input.group1").attr("disabled", true);
}
}
Nevertheless, I have several rows so I thought I would make a group ID for each of the "Weekly" checkbox and then the following boxes to be part of that same class. How can I deal with checkboxes on all rows? Should I assign each checkbox a class and then work with that? What would be the best solution?