Reputation: 621
I am trying to get the review rating value by name for storing a value in a database. I am using this library for the review rating control. I can't find out a way to get the name value. My code markup is
<input name="rating-id" type="text" id="rating-id" class="rating-kv" min=0 max=5 step=0.2 data-size="sm">
$('#rating-id').rating().on('rating.change', function(event, value, caption) {
$("#rating-id").value;
});
Is there way to get it's name value while changing review rating or is there a better review rating plugin for use.
Upvotes: 0
Views: 630
Reputation: 20039
Try using change
event.
Note the plugin events rating.change
, rating.clear
and rating.reset
are not working
$(function() {
$('#rating-id').rating();
$('#rating-id').on('change', function(event) {
console.log($(this).attr('name'), $(this).val())
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-star-rating/4.0.5/css/star-rating.min.css" media="all" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-star-rating/4.0.5/js/star-rating.min.js" type="text/javascript"></script>
<input name="rating-id" type="text" id="rating-id" class="rating-kv" min=0 max=5 step=0.2 data-size="sm">
Upvotes: 1