I want give the opportunity to the user to change the rating value of a product, but it is not working after refreshing the page. For example, when he goes to a new product that he did not rate, he can change the rating value again and again before refreshing the page. But after refreshing the page he can change the rating value of the same product, but the alert for the "ratingValue2" is not working and the database is not updating.
Here is my PHP code.
$jsqla3 = mysql_query("select * from user_star_rate where product_id='$product_id' and email='$visit_email'") or die(mysql_error());
$jfeta3 = mysql_fetch_assoc($jsqla3);
if($jfeta3 != null) {
$ratea = $jfeta3['rate_value'];
}
Here is my HTML code.
<input class="rating form-control input-star-rate" id="<?php echo $rateid; ?>" name="rating" value="<?php echo $ratea; ?>" data-min="0" data-max="5" data-step="0.3" data-size="xs" style="display: none; text-align: center;"/>
Here is my javaScript code.
$(function(){
$(document).ready(function(e) {
var $stars = $('.input-star-rate');
$stars.bind('change', function() {
var $this = $(this);
var ratingValue = $this.val();
var ratingValue2 = parseFloat(ratingValue);
alert(ratingValue2);
});
});
});