I’m a total noob when it comes to coding and was just wondering if someone can help. I have 4 switches ( refer to image) and would like only one of them to be able to be turned on at a time. If one is turned on i would like all others to turn off…if that makes sense. If someone could provide the code to do this i would be very grateful. Thanks in advance for any assistance!
const switchIds = ['switch1', 'switch2','switch3', 'switch4']//use the actual element ID instead.
$w.onReady(() => {
switchIds.forEach(e => {
$w('#'+ e).onChange(({target}) => {
if(target.checked){
switchIds.filter(id => id !== target.id)
.forEach(id => $w('#' + id).checked = false);
}
})
})
})
Thankyou! Much appreciated.