Search.../

checked

Sets or gets whether a checkbox is checked.

Description

Setting the checked property to true places a check in the checkbox. Setting it to false removes the check from the checkbox.

Getting the checked property returns whether the checkbox is checked or unchecked.

Type:

booleanRead & Write

Was this helpful?

Get whether a checkbox is checked

Copy Code
1let isChecked = $w("#myCheckbox").checked; // true
Get whether a checkbox is checked when it changes

Copy Code
1$w.onReady(function () {
2
3 $w("#checkbox1").onChange((event) => {
4 let isChecked = $w('#checkbox1').checked;
5 });
6
7});
Set a checkbox to be checked

Copy Code
1$w("#myCheckbox").checked = true;
Toggle whether a checkbox is checked

Copy Code
1let myCheckbox = $w("#myCheckbox");
2myCheckbox.checked = !myCheckbox.checked;
Enable the submit button when the checkbox is checked

This example enables the submit button when the accept terms checkbox is checked and disables it when unchecked.

Copy Code
1$w('#acceptTermsCheckbox').onChange((event) => {
2 if ($w('#acceptTermsCheckbox').checked) {
3 $w('#submitButton').enable();
4 } else {
5 $w('#submitButton').disable();
6 }
7});