# Show or hide button depending on Database data

**URL:** <https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [November 11, 2022, 7:25am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605 "2022-11-11T07:25:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivrifogel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ivrifogel/32/35560_2.png) [@ivrifogel](https://forum.wixstudio.com/u/ivrifogel)\
**Post date:** [November 11, 2022, 7:25am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/1 "2022-11-11T07:25:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![priyrajsingh](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/priyrajsingh/32/25827_2.png) [@priyrajsingh](https://forum.wixstudio.com/u/priyrajsingh)\
**Post date:** [November 11, 2022, 11:22am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/2 "2022-11-11T11:22:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [November 11, 2022, 11:45am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/3 "2022-11-11T11:45:30Z")

</div>

You are writing about a created VOTING-SYSTEM, but you do not give any-details about it.

1. Is it a CUSTOM-VOTING-SYSTEM?
2. Or is it some kind of already predefined stuff or even an APP?
3. Did you use CODE for it, ir did you use simply again just predefined stuff like DATASETS and the PROPERTY-PANEL ?
4. How did you structure your DATABASE ?

@priyrajsingh

> 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?

---

<div class="post-metadata">

**Author:** ![priyrajsingh](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/priyrajsingh/32/25827_2.png) [@priyrajsingh](https://forum.wixstudio.com/u/priyrajsingh)\
**Post date:** [November 11, 2022, 3:59pm UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/4 "2022-11-11T15:59:05Z")

</div>

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 :100:

Should I send you the Project link here? @russian-dima

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [November 11, 2022, 4:37pm UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/5 "2022-11-11T16:37:52Z")

</div>

I can take a look.

You can send me your link onto my e-mail, if it is not for public viewing.

[velo-ninja@outlook.com](mailto:velo-ninja@outlook.com)

---

<div class="post-metadata">

**Author:** ![ivrifogel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ivrifogel/32/35560_2.png) [@ivrifogel](https://forum.wixstudio.com/u/ivrifogel)\
**Post date:** [November 13, 2022, 2:42am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/6 "2022-11-13T02:42:43Z")

</div>

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.

 ![](https://us1.discourse-cdn.com/wix/original/3X/8/3/838e785b7500972d9d6690123ec6a0f09e7832ff.png)

 ![](https://us1.discourse-cdn.com/wix/original/3X/8/3/83470645f730b74b736393927763b346a273b842.png)

- 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.

[https://us1.discourse-cdn.com/wix/original/2X/9/9c989e711f7112cc234b36a31d3c418f6546b39f.mp4](https://us1.discourse-cdn.com/wix/original/2X/9/9c989e711f7112cc234b36a31d3c418f6546b39f.mp4)

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:

 ![](https://us1.discourse-cdn.com/wix/original/3X/0/c/0ce9b644865e37c6c909b33c6c439492ed38f1a4.png)

Thank you very much for your help and sorry for the late reply!  
Ivri.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [November 13, 2022, 11:41am UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/7 "2022-11-13T11:41:37Z")

</div>

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?

1. You get the currentItem
2. you increase the value inside of → “votes” db-field
3. you save the new value inside your db
4. 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/refresh)

[https://www.wix.com/velo/reference/wix-dataset/dataset/onaftersave](https://www.wix.com/velo/reference/wix-dataset/dataset/onaftersave)

---

<div class="post-metadata">

**Author:** ![ivrifogel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ivrifogel/32/35560_2.png) [@ivrifogel](https://forum.wixstudio.com/u/ivrifogel)\
**Post date:** [November 20, 2022, 1:57pm UTC](https://forum.wixstudio.com/t/show-or-hide-button-depending-on-database-data/10605/8 "2022-11-20T13:57:18Z")

</div>

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:

> **['Like' system | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/like-system)**
>
> Hi everyone,
> I'm trying to create a website where only logged-in users can vote for as many items as they want, but only once. It's the same idea as a social media site; you can 'like' whatever you'd like, but only once.
> 
> Here's what works:
> \- Only...

I’d really appreciate it if you could take a quick look and help me out.  
Thanks for your help!
