How do I limit the number of registration submit to Database

I’m trying to create a tournament with limited team register in the tournament, how should I limit the number that will submitted to my database?

adding count function to Submit button under OnClick?

How to do it?
Thanks in advance for the help.
Appreciated.

Hi,

Can you please send a picture of your database fields?

Thanks,
Sapir


So right now I din’t set the limit, so if there is too much team register then I will be in problem.
I hope to set a limit to I can control the input from public.

So there is “Team Name” as the main field
and the rest will be:
-Team Lead ID
-Team Leader Name

  • IC 1
  • Contact 1
  • Player 2
  • IC 2
  • Contact 2
  • Player 3
  • IC 3
  • Contact 3
  • Player 4
  • IC 4
  • Contact 4
  • Player 5
  • IC 5
  • Contact 5

Also there is image upload that is not compulsory,
and also agree to T&C tick which is required.

Please send also a picture of your database (the table), I don’t understand how the team players are saved in the collection.

@sapirh


Hmmm, is this okay? Sry I can’t reveal the data thou…

Hi,

I suggest you to add a method at the onReady() function that runs before the user starts interacting with your page. The function will count how many teams have registered already and if they rich the limit change all the user input’s properties to be hidden and add a pup up message or lightbox.

$w.onReady( function() {
  
} );

In order to get the amount of items use Query() function ( results.items.length )

In order to hide the user’s input use hide() function.

Here you can read about light-box

Best of luck!
Sapir

1 Like


This is where I got so far…I really have no idea how to resolve this…

So basically how do I retrieve the data of Team’s Name and count it, after the count result is =16 and then the activate the #box1 to fade away?

Now I have the result of count, how do I use the results to make an if else statement?
like if result =>16 then #box1 is hidden, else do nothing.

Currently my code is like this…

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-data’;

$w.onReady( function () {
//TODO: write your page related code here…

wixData.query(“MOBILE_LEGEND_DOJO_ROUND_2”)//Your collection name here
.count() // Counts how many items in collection
.then((results)=> {
console.log(results); //2
})
if ( $w(“#box1”).hidden ) {
$w(“#box4”).show();
}
else {
$w(“#box4”).hide();
}
});

Hi,

After you got the amount of teams in the database, inside the Query() handler add the condition.


wixData.query("MOBILE_LEGEND_DOJO_ROUND_2")
.find()
 .then((results)=> {   
   if(results.items.length>= 16)
   {
        $w("#box1").hidden;
   
    }

})

Best,
Sapir