redirect based on boolean value

Hi There,
I have a member profile page with the sign-in functionalities etc. After users have filled in the form on their dynamic page, they have to agree with the Terms and conditions by using the boolean button (‘Agree’) which is stored in the #dynamicDataset and then their submission is completed. When user want to update their form input they should not be directed again to the terms and conditions page. Therefore I use the following code:
Button1 is the submit/update button on the dynamic form page.
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

// Query The “Free1 Database” if user has already submitted the form not go to terms and conditions, just save changes
export function button1_click() {
wixData.query(“Free1”)
const booleanValue = $w(“#dynamicDataset”).getCurrentItem().Agree
if (booleanValue === true ) { wixLocation.to(‘https://www.purepropertycentralportugal.com/member-login’);
}
else {
wixLocation.to(‘https://www.purepropertycentralportugal.com/terms-and-conditions’);
}
}

However, after the boolean is true in the database, the user is still directed to terms and conditions page. Could anyone see what is not correct in the code?
Thank you!
Vincent

As you are using a checkbox to get the boolean value, then you should look at using Checkbox
https://www.wix.com/corvid/reference/$w.Checkbox.html

You will see in this tutorial here ( https://www.wix.com/corvid/example/checkbox-dropdown ) that within the code that it looks for if the checkbox is ticked with this line of code.

  if ($item('#optionCheckbox').checked) { 

You will get a better understanding for it by checking out this Vorbly sample here.
https://www.vorbly.com/Vorbly-Code/WIX-REPEATER-MULTIPLE-CHECKBOX-FILTERS

HI @givemeawhisky , thank you for your answer. But how to refer to a checkbox in my database? Because the checkbox I want to check is not on the page I am storing the code, but in the database collection.

Have a look at this previous forum post and it should help you more.
https://www.wix.com/corvid/forum/community-discussion/redirect-to-other-url-if-boolean-value-in-collection-false-resolved

And these too.
https://www.wix.com/corvid/forum/community-discussion/hide-button-boolean-wix-database
https://www.wix.com/corvid/forum/community-discussion/conditionally-show-hide-a-button-on-a-repeater-control