Hi,
I created a voting system on Wix where once you vote on an item, the voting button disappears. However, once the page is re-loaded, the button appears once again. I have a member system where only users that have signed up can vote. I wanted to make it so that users can vote once until the end of the day (midnight) and then it resets. How can I do this?
Thanks,
Ivri.
Enable or Disable the Voting Button based on the Database Query.
If there is already a Vote Exist, Disable the Button on Page Load.
It’s That Simple!
You are writing about a created VOTING-SYSTEM, but you do not give any-details about it.
- Is it a CUSTOM-VOTING-SYSTEM?
- Or is it some kind of already predefined stuff or even an APP?
- Did you use CODE for it, ir did you use simply again just predefined stuff like DATASETS and the PROPERTY-PANEL ?
- How did you structure your DATABASE ?
Enable or Disable the Voting Button based on the Database Query.
If there is already a Vote Exist, Disable the Button on Page Load.
It’s That Simple!
Why you did not provide any simple example-code?
Further…
a) only users that have signed up can vote → that already works?
b) I wanted to make it so that users can vote once until the end of the day (midnight) → that already works?
Where is your current running (not running code) of your issued case?
Hey there! Can you do me a favor?
As you’re a “Top Contributer” and a Velo Certified…
I want to you look at the Velo Certification Project that I have Created - Phone Book Project.
Let me know the necessary Improvements, I am about to submit the Project.
It’s Completed
Should I send you the Project link here? @russian-dima
I can take a look.
You can send me your link onto my e-mail, if it is not for public viewing.
Hi again,
Here’s what I’ve already established and fully works:
-
All pages are only available to users that have already signed up/signed into the website meaning only signed-in users can vote.
-
Users can input their own quote, and once they press the submit button it adds the following data into the ‘Quotes’ Database: Quote, Author, and Votes. (The votes are automatically set to 0 when a new quote is created.
-
Under that, there is a repeater, which takes all the data from the ‘Quotes’ database and creates as many ‘blocks’ if you will, as needed. On those blocks, the quote, author, and the number of votes are presented.
-
There is also a vote button on the blocks which increases the number of votes for that specific quote by 1 and makes the vote button disappear.
What I need help with:
-
Once the vote button is clicked, the incrementation works, but for the vote to update, the page needs to be reloaded. What code do I need to implement for the number to increment without reloading the page?
-
The incrementation only adds to the first quote/top quote instead of the quote that the vote button was clicked on, meaning that I would click on a vote button on a specific quote, but it would add +1 to a different quote.
-
The vote button disappears once it’s clicked, but after the page is reloaded, the vote button comes back. I need a user to be able to vote only once a day, resetting at midnight.
Apologies for not including any of my code, I wasn’t sure how these things usually work. Here is the code that happens once the VOTE button is clicked:
Thank you very much for your help and sorry for the late reply!
Ivri.
Please show your code in a nice looking and well formated CODE-BLOCK next time, instead of showing your code as a pic.
Anyone wants to waste time to RETYPE your coder from a pic, thanks.
What does do your provided code?
- You get the currentItem
- you increase the value inside of → “votes” db-field
- you save the new value inside your db
- now after you have saved your value, you need to refresh, right?
So what about a refresh-action after save-process???
https://www.wix.com/velo/reference/wix-dataset/dataset/refresh
https://www.wix.com/velo/reference/wix-dataset/dataset/onaftersave
Hi @russian-dima ,
Apologies for getting back to you on a late note.
I’ve resolved many of the problems I’ve had before, for example, the vote number updating immediately without reloading the page, etc.
I created a post that shows my new targets as of now:
I’d really appreciate it if you could take a quick look and help me out.
Thanks for your help!