$(".rating-input").on("click", function () {
var id = $(this).attr("star-attr");// значение каждого инпута по отдельности
var val = $(this).val();
$.ajax({
type: "POST",
url: "./PHP REQUIRE/addtostars.php",
data: "id=" + val + "&id1=" + id, // Отправка сразу нескольких значений через ajax
dataType: "html",
cache: false,
success: function (data) {
console.log(data);
if (data >= '0'){
alert ('вы голосовали');
} else {
alert ('ваш голос учтен');
}
}
});
});
echo '
<div class="order_right">
<div class="wrap_stars">
<form class="form-rating" method="POST">
<fieldset>
<legend></legend>
<div class="rating-group" id="el_555' . $row["products_id"] . '">
<input star-attr="' . $row["products_id"] . '" class="rating-input" id="mod1' . $row["products_id"] . '" name="radio-rating" type="radio" value="1" >
<label class="rating-star" for="mod1' . $row["products_id"] . '"></label>
<input star-attr="' . $row["products_id"] . '" class="rating-input" id="mod2' . $row["products_id"] . '" name="radio-rating" type="radio" value="2">
<label class="rating-star" for="mod2' . $row["products_id"] . '"></label>
<input star-attr="' . $row["products_id"] . '" class="rating-input" id="mod3' . $row["products_id"] . '" name="radio-rating" type="radio" value="3">
<label class="rating-star" for="mod3' . $row["products_id"] . '"></label>
<input star-attr="' . $row["products_id"] . '" class="rating-input" id="mod4' . $row["products_id"] . '" name="radio-rating" type="radio" value="4">
<label class="rating-star" for="mod4' . $row["products_id"] . '"></label>
<input star-attr="' . $row["products_id"] . '" class="rating-input" id="mod5' . $row["products_id"] . '" name="radio-rating" type="radio" value="5">
<label class="rating-star" for="mod5' . $row["products_id"] . '"></label>
</div>
</fieldset>
<div class="count_block">
<!-- Статистика -->
<ul class="count" >рейтинг : ' . round($row["rating"], 1 ) . '</ul>
</div>
</form>
</div>
</div>
</li>
</div>
';