Two checkboxes to enable two buttons?

Hello! Been trawling through forums for hours and can’t seem to crack this one.

Have got two individual checkboxes (can’t be multi-checkboxes as i need to link some of the text to pdf’s) that once both are checked, the two buttons below can then be selected. Code currently isnt working but feel like we’re close! Currently the checkboxes can be selected but buttons still remain disabled.

Currently using code:

$w.onReady(() => {
$w(‘#checkbox1’).checked=false
if ($w(‘#checkbox1’).checked==true)
$w(‘#checkbox2’).checked=false
if ($w(‘#checkbox2’).checked==true){

    $w('#button31').enable();
    $w('#button32').enable();

} else $w('#button31').disable();
 $w('#button32').disable();
})

Any help much appreciated!!

I would say, only if both checkboxes are checked and the user is well informed → they can pass —> right?

$w.onReady(() => {
    // Initially disable the buttons
    $w('#button31, #button32').disable();
    // Event listener for checkbox1
    $w('#checkbox1').onChange(() => {check_Checkboxes();});
    // Event listener for checkbox2
    $w('#checkbox2').onChange(() => {check_Checkboxes();});

    // Function to check both checkboxes and enable/disable buttons accordingly
    function check_Checkboxes() {
        if ($w('#checkbox1').checked && $w('#checkbox2').checked) {
            $w('#button31, #button32').enable();
        }
        else {$w('#button31, #button32').disable();}
    }
});

In SUMMARY, without COMMENTS… → plain, clear CODE

$w.onReady(()=> {
    $w('#button31, #button32').disable();
    $w('#checkbox1, #checkbox2').onChange(()=> {check_Checkboxes();});
    //------------------------
    function check_Checkboxes() {
        if ($w('#checkbox1').checked && $w('#checkbox2').checked) {
            $w('#button31, #button32').enable();
        }  else {$w('#button31, #button32').disable();}
    }
});

oh my goodness, Code Ninja you’re amazing thankyou so much!!

1 Like

Did it work for you ? :grinning: