whats wrong with this code I have here? I have spent hours and hours trying to figure it out. I want my checkbox’s on my registration page to allow multiple selections to be checked/un-checked and I also want them to be repeated onto this input field I renamed the id " #testValue ". my website is sweathands.com and the area I am trying to work on is my registration page. I really would appreciate the help. I am getting an error message when I preview the website and my error message is this :
Here is the error message: Loading the code for the Registration popup. To debug this code, open f5sse.js in Developer Tools. There was an error in your script. The element selector function (usually $w) cannot be used before the page is ready
Here is the code for my registration page:
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
$w.onReady(function () {
$w(’ #registerbutton ‘).onClick(function () {
let email = $w(’ #email ‘).value;
let password = $w(’ #password ‘).value;
wixUsers.register(email, password)
.then(() => {
wixLocation.to (’/testing’);
})
})
})
export function ps4checkbox_click_1(event) {
" #PS4 "();
}
export function pccheckbox_click_1(event) {
" #PC "();
}
export function xboxcheckbox_click(event) {
" #XBOX “();
}
export function nintendoswitchcheckbox_click(event) {
“NintendoSwitch”();
}
export function mobilecheckbox_click(event) {
“Mobile”();
}
function pccheckbox() {}
if ($w(” #pccheckbox “).value === ‘’) { $w(” #pccheckbox “).value = ‘PC’; } else { $w(” #pccheckbox “).value = ‘’; }
if ($w(” #ps4checkbox “).value === ‘’) { $w(” #ps4checkbox “).value = ‘PS4’; } else { $w(” #ps4checkbox “).value = ‘’; }
if ($w(” #xboxcheckbox “).value === ‘’) { $w(” #xboxcheckbox “).value = ‘XBOX’; } else { $w(” #xboxcheckbox “).value = ‘’; }
if ($w(” #nintendoswitchcheckbox “).value === ‘’) { $w(” #nintendoswitchcheckbox “).value = ‘NintendoSwitch’; } else { $w(” #nintendoswitchcheckbox “).value = ‘’; }
if ($w(” #mobilecheckbox “).value === ‘’) { $w(” #mobilecheckbox “).value = ‘Mobile’; } else { $w(” #mobilecheckbox “).value = ‘’; }
function valueCombine() {
let checkedValue = $w(” #pccheckbox “).value + " " + $w(” #ps4checkbox “).value + " " + $w(” #xboxcheckbox “).value + " " + $w(” #nintendoswitchcheckbox “).value + " " + $w(” #mobilecheckbox “).value;
$w(” #testValue ").value = checkedValue;
}
export function registerbutton_mouseIn() {
valueCombine();
}