Hello friends I would be happy if you help me …
I need help adding in the code on checkboxs when I add the first checkbox that adds to my database of customers and the second checkbox confirms the registration terms.
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
$w.onReady( function () {
$w(‘#submit’).onClick( () => {
wixUsers.register($w(‘#email’).value, $w(‘#password’).value,{
“contactInfo”: {
“firstName”: $w(‘#firstName’).value,
“lastName”: $w(‘#lastName’).value,
“emails”: [$w(‘#email’).value],
“birthday”: $w(‘#birthday’).value,
“phones”: [$w(‘#phone’).value],
}
} )
.then( (result) => {
let status = result.status; // “Active”
let user = result.user;
wixLocation.to(“/home”);
} );
});
});
Ok, if I understand you want to check if the checkboxes have been ticked before you continue with you register code? If yes… look below
$w('#submit').onClick( () => {
if ($w("#checkbox1").checked && $w("#checkbox2").checked) {
registerUser(); // Created that as a function instead
} else {
// One or both checkboxes are not checked by use
// Show them some message
}
});
export function registerUser() {
wixUsers.register($w('#email').value, $w('#password').value,{
"contactInfo": {
"firstName": $w('#firstName').value,
"lastName": $w('#lastName').value,
"emails": [$w('#email').value],
"birthday": $w('#birthday').value,
"phones": [$w('#phone').value],
}
} )
.then( (result) => {
wixLocation.to("/home");
} );
}
Information about chexkboxes
I hope that this will help you or at least give you some tips on the way. Good luck and happy coding.