Hi there,
Everyone knows the usual form in which the user gets to check a single checkbox and submit it by a button - to set a given Boolean value to True or False on the database. This is used for example when the user have to give their consent about getting newsletters, etc.
I want to set up a button without the need to get the user to check the checkbox - and just click on a single button to set the Boolean value to True.
I’ve named my Boolean field in the data collection as callsApproved and then I tried to connect the button to a Dataset in the page. But to my surprise, the callsApproved field is greyed out and I cannot choose it to be linked to the button itself.
Can you please suggest how this can be done right?
Thank you
Hi,
You could put the following setFieldValue code in the button onClick event where the dataset on the page is named “dataset1”.
$w('#dataset1').setFieldValue("callsApproved",true);
Hi, I have a problem with saving boolean value, don’t want to start a New post. Here is the code
let value = $w(“#switch2”).checked ;
let myCheckbox2 = $w(“#switch2”);
myCheckbox2.checked = !myCheckbox2.checked;
$w(“#dataset2”).setFieldValue(“status”, false );
I succeed to change switch state to off but the boolean value didn’t save in field in Preview and Live . I check all my permissions to DB are settled to Anyone. dataset READ/WRITE. My second option could be to save the switch2 state value once is settled to false but tried to find API references to save switch state value…Found nothing about!