voting counter

So im trying to display the count of how many votes a page has on my site. People can vote on a project like on this project www.archbestproject.com/2000 people can vote but how can i display the voting counter on each page?

Hello

Check this answer out !

Best
Massa

I am not sure if I understand his issue. I have attached this image. im trying to allow when people vote the total voting actually changes right away, live. can you tell me what I need to do to the voting and what do I need to do to where the voting count appears so voting count updates once clicked on vote?

Hi,
It depends on how you save the data, whether you save each vote or save the total count of votes.
Once a vote was submitted, you can use a simple query to count the number of votes (in case you save each vote). check out this code for example:

// this code is in the event that runs after a vote was submitted 
wixData.query("collection")
  .eq("vote", "voteNumber1")
  .find()
  .then( (results) => {
 let count = results.items.length;
    $w('#text4').text = count.toString(); 
  } )
  .catch( (err) => {
 let errorMsg = err;
  } );
}

Good luck :slight_smile:

How would I save each vote?

What would be the “collection“ ”vote” “voteNumber1” ? In the image I have a form that people can fill out and vote then I have the total votes text