The values do not pass for "id" and "rate_number" from database."ratingValue" is working, but "id" alert and "num" alert are not working.
Here is my PHP code.
$jsqla = mysql_query("select id,name,rate_score,rate_number,video_image from products where genre='$genre' limit 0,5");
if($jrowa['rate_number'] > 0){
$ratea = $jrowa['rate_score'] / $jrowa['rate_number'];
}else{
$ratea = 0;
}
Here is HTML code.
<div class="col-sm-2 portfolio-item" style="width: 20%;">
<input class="rating form-control input-star-rate" 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;"/>
</div>
Here is jQuery code.
$(function(){
$(document).ready(function(e) {
var $stars = $('.input-star-rate');
$stars.bind('change', function() {
var $this = $(this);
var ratingValue = $this.val();
alert(ratingValue);
var id = $this.attr("id");
alert(id);
var num = parseInt("$this.attr("rate_number")")+1;
alert(num);
});
});
});