Reddit-like voting system and sorting list by "score"

Hey guys,
I need to create Reddit-like voting system.
Users can vote up (+1 point) and down (-1 point). When they clicked upvote, the button is active, so when they click active button it backs to 0 and they. When upvote is active and they click on downvote, it is -1 point.

My goal is to display list of items and sort them from highest score. The problem is - I need to keep scoring as separate table in items as number type to be able to sort list and I can’t do good function for that.


  • UPVOTE (inactive)
  • UPVOTE (active - when is upvoted)
  • DOWNVOTE (inactive)
  • DOWNVOTE (active - when is downvoted)

I have a problem with proper function to calculate SCORE.

UPVOTE post = SCORE + 1
Uncheck UPVOTE post = SCORE -1
Uncheck DOWNVOTE post = SCORE +1

The problem is: user UPVOTE, so SCORE = 1 and then he DOWNVOTE directly and SCORE = 0, but it should be -1. It is not needed to uncheck UPVOTE before clicking DOWNVOTE. I can’t disable that because user needs to have opportunity to not vote on posts.

How to do that properly? UPVOTE and DOWNVOTE columns work properly - it just add/delete current user.

Hi Dawid,

I am not sure if I have understood your post correctly, but if you want the downvote to go from 1 to -1 you can add numerous actions for one click, for example:

Set action on the MINUS button to SET FIELD -1 and change ‘when does this happen’ to IF FIELD IS GREATER THAN 1.

Set another action on the MINUS button that says SET FIELD TO -2 and change ‘when does this happen’ to IF FIELD IS EQUAL TO 1.

Set an action on the PLUS button that says SET FIELD TO +2 and change ‘when does this happen’ to IF FIELD IS EQUAL TO -1.

These solutions will let you skip the 0, is this what you are looking for?


I don’t need to skip 0. I should keep that to let user to unvote post and not add 1 or -1.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.