PHP Classes

Thumbs up & down: two votes possible

Recommend this page to a friend!

      Bootstrap PHP Comment System with MySQL  >  All threads  >  Thumbs up & down: two votes possible  >  (Un) Subscribe thread alerts  
Subject:Thumbs up & down: two votes possible
Summary:Only one vote should be allowed
Messages:3
Author:Michael Beck
Date:2016-02-02 07:23:03
 

  1. Thumbs up & down: two votes possible   Reply   Report abuse  
Picture of Michael Beck Michael Beck - 2016-02-02 07:23:03
On the demo here, I can click on "Like" and then on "Dislike", and the vote on "Like" is still there.

I would be better, when I click the "Dislike", my vote on "Like" would transfer to "Dislike"

  2. Re: Thumbs up & down: two votes possible   Reply   Report abuse  
Picture of Vishv Sahdev Vishv Sahdev - 2016-02-02 07:50:20 - In reply to message 1 from Michael Beck
<span class="glyphicon glyphicon-thumbs-up onclick" aria-hidden="true" aria-value="214" id="UP214"> 2 </span><span class="glyphicon glyphicon-thumbs-down onclick" aria-hidden="true" aria-value="214" id="DOWN214"> 0 </span>
-------------------------------------------------
//class update onclick

$(".onclick").one("click",function(){
var id = $(this).attr("aria-value");
$.ajax({
url : "/widget/com",
type: "POST",
data : {"type": "dislike","id":id},
success: function(data)
{
$("#DOWN"+id).text(" " +data);
}
});
$(this).text(d + "v");
});

  3. Re: Thumbs up & down: two votes possible   Reply   Report abuse  
Picture of Vishv Sahdev Vishv Sahdev - 2016-02-02 07:58:36 - In reply to message 2 from Vishv Sahdev
<span class="glyphicon glyphicon-thumbs-up onclick" data-id="UP" data-value="like" aria-hidden="true" aria-value="214" id="UP214"> 2 </span><span class="glyphicon glyphicon-thumbs-down onclick" data-id="DOWN" data-value="dislike" aria-hidden="true" aria-value="214" id="DOWN214"> 0 </span>

$(".onclick").one("click",function(){
var id = $(this).attr("aria-value");
var data_id = $(this).attr("data-id");
var data_value = $(this).attr("data-value");
$.ajax({
url : "/widget/com",
type: "POST",
data : {"type": data_value,"id":id},
success: function(data)
{
$("#"+data-id+id).text(" " +data);
}
});
$(this).text(d + "v");
});