Disable Checkbox if another Checkbox is Checked

Hello Wix Fam! I could use some help.

I am working with two check boxes for a “yes/no” response in a custom form. I want to disable one option if the other is selected. I can’t seem to get the code working even though this seems like such a simple task! I have listed the code below. Any help would be appreciated.

NOTE: I chose not to use radio buttons because 1) I wanted more freedom with customization and 2) I have an “onClick” event to show collapsed fields that wouldn’t have been feasible with the radio button.


export function disableCheckBox() {
 let isChecked = $w("#physicalAddressYes").checked;

 if ($w('#physicalAddressYes').checked === true) {
        $w('#physicalAddressNo').disable();
    } else {
        $w('#physicalAddressNo').enable();
    }

}

export function physicalAddressYes_click(event) {
    displayAddressInput();
}

1 Like

you might need to call the function too

export function physicalAddressYes_click(event) {
    displayAddressInput(); 
    disableCheckBox();
}