Alex Rivera | Logout

How can you make a vote-up-down button like in Stackoverflow?

Asked 2009-04-05T16:07:30.077
33

Problems

  1. how to make an Ajax buttons (upward and downward arrows) such that the number can increase or decrease
  2. how to save the action af an user to an variable NumberOfVotesOfQuestionID

I am not sure whether I should use database or not for the variable. However, I know that there is an easier way too to save the number of votes.

How can you solve those problems?

[edit]

The server-side programming language is Python.

Edit
Report

1 Answer

8

A couple of points no one has mentioned:

  • You don't want to use GET when changing the state of your database. Otherwise I could put an image on my site with src="http://stackoverflow.com/question_555/vote/up/answer_3/".
  • You also need csrf (Cross Site Request Forgery) protection
  • You must record who makes each vote to avoid people voting more than once for a particular question. Whether this is by IP address or userid.
answered 2009-04-05T20:16:48.807

Your Answer