# Two checkboxes to enable two buttons?

**URL:** <https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935>\
**Category:** Ask the community\
**Tags:** wix-studio, code\
**Created:** [January 25, 2025, 2:42am UTC](https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935 "2025-01-25T02:42:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rachel\_Tinkler](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rachel_tinkler/32/104195_2.png) [@Rachel\_Tinkler](https://forum.wixstudio.com/u/Rachel_Tinkler)\
**Post date:** [January 25, 2025, 2:42am UTC](https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935/1 "2025-01-25T02:42:42Z")

</div>

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();
})

```

 ![Screenshot 2025-01-25 at 3.41.56 PM](https://us1.discourse-cdn.com/wix/original/3X/4/6/461497e721089c64587f7b3a2a73bdeb4b4d51ae.png)

Any help much appreciated!!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 12:48pm UTC](https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935/2 "2025-01-25T12:48:26Z")

</div>

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

```javascript
$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

```javascript
$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();}
    }
});

```

---

<div class="post-metadata">

**Author:** ![Rachel\_Tinkler](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rachel_tinkler/32/104195_2.png) [@Rachel\_Tinkler](https://forum.wixstudio.com/u/Rachel_Tinkler)\
**Post date:** [January 25, 2025, 9:20pm UTC](https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935/3 "2025-01-25T21:20:02Z")

</div>

> [@CODE-NINJA](#):
>
> ```javascript
> $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!!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [January 25, 2025, 9:34pm UTC](https://forum.wixstudio.com/t/two-checkboxes-to-enable-two-buttons/67935/4 "2025-01-25T21:34:50Z")

</div>

Did it work for you ? 😀
