Is my code correct? It seems not working for me. Could someone help me out with issue.
I am trying to enable “Button 1” when “checkbox 1” is marked otherwise disable. My website link below and code is in Join Flock Now 1 dynamic page . https://flocktravel1.wixsite.com/-site/
import wixData from ‘wix-data’;
$w.onReady(() => {
$w(‘#checkbox1’).onChange(nextButtonEnableDisable);
});
function nextButtonEnableDisable() {
if (($w(‘#checkbox1’).checked
$w(‘#button1’).enable();
} else $w(‘#button1’).disable();
}
Thequestion is, when do you wanna fire the action-event?
When site has loaded (automaticaly) or on a button-press?
And here an example…
https://russian-dima.wixsite.com/meinewebsite/enable-button-check
When site has loaded automatic I want button to be inactive, after clicking check mark, button has to activate
Ok, you want that the button is disabled when the site loads and only if the Check-Box is activated (marked/checked), only then the button has to be activated right?
Yes that is what I am trying to achieve
Then try this one…
$w.onReady(() => {
$w('#checkbox1').checked=false
if ($w('#checkbox1').checked==true) {
$w('#button1').enable();
} else $w('#button1').disable();
})
Updated-example here…
https://russian-dima.wixsite.com/meinewebsite/enable-button-check
Ok let me check. Thank you
I used suggested code. I got exclamation error on ( $w ( ‘#checkbox1’ ). checked == true ) and used “===” instead “==”, now there is no error but still code doesn’t work. The button is disabled state when page has loaded with checkbox unmarked, when I mark the checkbox, the button still inactive or doesn’t become active. Should I do change anything in settings…
Here is the link below for you to see
https://flocktravel1.wixsite.com/-site/join-flock-now-1/FTNRTFEB2022-0001
Hello Parthasarathy,
- did you connect the checkbox-action with your code? —> “onChange-event-handler” ?
The whole code should look like this…
$w.onReady(() => {
$w('#checkbox1').checked=false
if ($w('#checkbox1').checked==true) {
$w('#button1').enable();
} else $w('#button1').disable();})
export function checkbox1_change(event) {
if ($w('#checkbox1').checked==true) {
$w('#button1').enable();
} else $w('#button1').disable();
}
Take one more time a look at my example, i have updated it…
https://russian-dima.wixsite.com/meinewebsite/enable-button-check
And as you can see, it works even with exclamination-error 
($w(‘#checkbox1’).checked==true)
But you are right, it’s better to use…
($w(‘#checkbox1’).checked===true)
I am just lazy😆
Yes you are right. But make it work I changed checkbox1_change ( event ) to checkbox1_change ( event, $w )
Now all is fine. It is working overall. Thank you very much 


Don’t forget to give a like if you liked my answers, even although i can’t buy anything with it 