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();
}
Hello Parthasarathy,
1) 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😆
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
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