I wish someone can help me with this. I'm not not so good in codes.
My site is https://www.mascusa.com/membership-index.
In this page I've 4 datasets connected to 4 databases. As you can see the table goes like this:-
Regular Membership 67, Silver Membership 10, Platinum Membership 2 and Student Membership 3.
But, lately I was asked to add another membership to be calculated and is called
Total New Membership.
At the moment I've codes as shown below and it works. Does anyone know how I can add
code to calculate all the new members in these 4 database and shown in the table?
Any help will be greatly appreciated. Here is my code shown below
wixData.query("paymentForm01")
.count()
.then( (num) => {
let allResults = num;
$w("#regularTotal").text = allResults.toString();
} );
wixData.query("paymentForm012")
.count()
.then( (num) => {
let allResults = num;
$w("#silverTotal").text = allResults.toString();
} );
wixData.query("paymentForm013")
.count()
.then( (num) => {
let allResults = num;
$w("#platinumTotal").text = allResults.toString();
} );
wixData.query("StudentMembership")
.count()
.then( (num) => {
let allResults = num;
$w("#studentTotal").text = allResults.toString();
} );
wixData.query("paymentForm01")
.count()
.then( (num) => {
let TotalRegularMembers= num;
wixData.query("paymentForm012")
.count()
.then( (num2) => {
let TotalSilverMembers= num2;
wixData.query("paymentForm013")
.count()
.then( (num3) => {
let TotalPlatinumMembers= num3;
wixData.query("StudentMembership")
.count()
.then( (num4) => {
let TotalStudentMembers= num4;
let grandtotal = TotalRegularMembers + TotalSilverMembers + TotalPlatinumMembers + TotalStudentMembers ;
$w("#grandTotal").text = grandtotal.toString();
} );
} );
} );
} );
Thanks for your reply.
Unfortunately, I don't have a field named "New". But there is a field for New/Renewal. This field was connected to a form that has a dropdown menu option for New or Renewal.
I have an idea, you can try -
Add 4 input elements to the page and a text element.
Hide all input elements.
Connect input elements to the field (maybe "new") in your 4 collections.
In the page, code gets the value of all four in four variables.
Add them all.
And show to value of the total in the text element.
Tip - Add your code in onReady() Function.