If you have some codes that cannot be selected together, but can be selected with other values, then you can make use of this logic check on the page. This is done on button click, so will not allow the selection of conflicting codes (if code 1 is selected and then code 3 is selected, it will unselect code 1).
Make row 1 and 3, row 2 and 4 exclusive to each other.
function pageReady(){
// define the pairs that can't be checked together
const pairs = [["1", "3"],["2", "4"]];
const conflictMap = {};
pairs.forEach(([a, b]) => {
conflictMap[a] = b;conflictMap[b] = a;
});
document.querySelectorAll(".cCheck").forEach(chk => {
chk.addEventListener("change", function () {
if (this.checked) {
const conflictVal = conflictMap[this.value];
if (conflictVal) {
const conflictChk = document.querySelector(`.cCheck[value="${conflictVal}"]`);
if (conflictChk) {conflictChk.checked = false;}
}
}
});
});
}