开发者

jquery vote up down, request for some help

I want to make some changes in the following piece of code.

The above example shows calculated number of votes (vote ups - votes down). And when you click on any thumbe, it disappears the thumbs and shows the updated votes. I want to make changes that in begining it shows vote up and vote down separately (which are stored in database separately). and after thumb up or down is pressed, it should not remove the thumbs, but it should show the updated vote up and down separatetly. As shown in the image below.

jquery vote up down, request for some help

Here are pieces of code:

Main p开发者_StackOverflowage having html/CSS and jquery code. http://pastebin.com/RC6dj6N5

vote processng code: http://pastebin.com/heszKyDc

PS. I have tried to change by myself but I could not do. Any help will be much appriciated. Thanks.


This is easy, with your php code you query the database to find out what the upvote is and what the down vote is. Output each to their respective thumb.

From here there is two ways(I would do the latter)
1: User clicks on a thumb and it posts back to the server and increments by 1(but there should be a rule to not become negative).

2: Use jQuery and ajax. Once the user clicks a thumb you use ajax to query the database and update the vote without a full page load. The ajax callback could update the vote at the page level.
Or
When the user clicks the thumb it auto increments the inner value by 1 and then updates the database behind the scenes, you could stop there or do #2 on the callback.


Could you show where you've gotten stuck?

It looks like you need to return curvotes[0] or curvotes[1] based on whether it's a vote up or down request instead of getEffectiveVotes.

Also, instead of just the votes_count div in the html, create one for up and one for down that get updated in the ajax success.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜