I was going through the forum and came across this and noticed you had some incorrect syntax like emanu2000 mentioned - in that you were missing the () on enable, show, disable and hide.
You don’t use parenthesis if you’re referring to states like enabled, which is checking the enabled property status of in this case a button, but you do in a function like enable(), which turns the property to true and enables the button so users can interact with it.
I didn’t test the code outright since I was unsure of the setup of the collections but it should look more like this:
$w.onReady(function () {
user.getEmail()
.then((email) => {
let userEmail = email; // e.g., "user@something.com"
wixData.query("Events")
.eq("usernameEmail", userEmail)
.count()
.then((num) => {
// Update the value of #submittedsofar
$w("#submittedsofar").value = num;
// Calculate remaining submissions
let initialNumber = $w("#initialnumber").value; // Ensure this element exists and has a value
let remainingSubmissions = initialNumber - num;
// Update the dataset fields
$w("#eventsdatasetsubmission").setFieldValue("eventNumber", num);
$w("#eventsdatasetsubmission").setFieldValue("remainingSubmissions", remainingSubmissions);
// Update the value of #remainingnos
$w("#remainingnos").value = remainingSubmissions;
// Enable or disable the button based on remaining submissions
if (remainingSubmissions > 0) {
$w("#buttonStart").enable();
$w("#startmessage").show();
} else {
$w("#buttonStart").disable();
$w("#startmessage").hide();
}
});
});
});