Button onClick event not working at all.

Hello,

I’ve used input fields as sorbonneId for users’ ID and, sorbonnePassword for users’ password, I’m trying to run an onClick handler using a Sign In Button. However, the button is supposed to compare the user’s ID and Password with the ones saved in Data Collection, named instructorLoginCredentials , but nothing happens when I click on it, the text field and logs don’t appear, which denotes it isn’t even comparing?

Here’s what I’ve tired:

import wixData from 'wix-data';
import wixLocation from 'wix-location';

console.log("Openinng : Signin Lightbox");
let password = $w('#sorbonnePassword').value;
let identity = $w('#sorbonneId').value;

export function signInButton_click(event) {
    $w('#infTxt').show('slideIn');
    console.log("Establishing Connection");
    wixData.query("instructorLoginCredentials")
        .eq('soInstructorIdentity', identity)
        .eq('soInstructorPassword', password)
        .find()
        .then((result) => {
 if (result.items.length > 0) {
                console.log("Credentials Found");
                wixLocation.to('/my-account/${results.items[0]._id}')
            } else if (result.items.length === 0) {
                $w('#notFoundMsgBox').show();
            } else {
                $w("#errorMessage").show();
                console.log("Credentials Not Found");
            }
        })
        .catch(err => {
            console.log("Unable to access collection: " + err)
        })
}

I have read articles from Corvid itself and also scrutinized a few answers, from forum questions, everything seems to be perfectly fine. How can I make it work?

Thanks,
Lee

Have you assigned the click function to the button in the editor? Click on the button and then, in the properties panel (Tools > Properties Panel) you need to add an onClick handler. Ensure that this handler is named " signInButton_click" and the code should run

It looks like you are also assigning values to identity and password outside of any function. You’ll probably want to assign these inside the onClick function. Otherwise the values will be assigned when the lightbox is opened and I am assuming the will be blank at that point.