2

I am using the star rating from this site : link But I can't seem to figure out how to get the rating from my radio buttons. I just need to display it in the console.log, the rest I can manage.

When the third is selected it looks like this:

HTML

If any more information is required, please ask, new to this.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260

3 Answers3

1

Get number of stars with the selected class .star-rating-on:

var rating = $('.star-rating-control .star-rating-on').length;

If there are more than one set of rating controls, please use a different parent selector, like article or .post:

$('article').each(function() {
    var rating = $(this).find('.star-rating-control .star-rating-on').length;
    // Do something...
}
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
1

Please use following code to get the value of rating:

$('.auto-submit-star').rating({ callback: function(value, link){ alert(value); } });

Replace .auto-submit-star with your selector

Aftab Muni
  • 161
  • 1
  • 8
0

The simple way is

  1. Create a form. Form will help you to post rating data.
  2. inside form create radio buttons as per your need.
  3. Call javascript api to change radio buttons into stars.
  4. There are 2 ways to get data from rating a. submit a form and get result using $_POST or $_GET or $_REQUEST b. Use ajax

Note:- This plugin return selected radio button value.

Manish Shukla
  • 1,355
  • 2
  • 8
  • 21