Hello! I’m trying to make 4 checkboxes be connected in a way that only one of them can be checked at a time. I found some lines of code from 2018 regarding this problem, but it doesn’t seem to wanna work for me. This is what I tried to use:
$w.onReady(function () {
for (let i = 1; i < 4; i++) {
$w(`#checkbox${i}`).onChange(() => {
const checkBoxes = ['#checkbox4', '#checkbox3', '#checkbox2', '#checkbox5'];
let filtered = checkBoxes.filter(item => item !== `checkbox${i}`);
filtered.forEach((checkbox) => {
$w(`#${checkbox}`).checked = false;
});
});
}
});
Did I do anything wrong here or is there another way you guys can suggest to make this possible?
Thank you in advance.