5 star rating A system using PHP and jQuery is used to evaluate various products or services on any web page in the best way interactive. The user can rate the content on a scale of 1 to 5 stars without reloading the page. We just give an example of scanning 1-5, otherwise the configuration of the jQuery scale can be changed. In this example, we used the Raty.JS plugin for interactive stars.
STEP-1 Create a simple html file as shown below
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <script type="text/javascript"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script type="text/javascript" src="http://testweb3.iecworld.com/jsdemo/js/lq_js_point/js/jquery.raty.min.js"></script> // Initialise Plugin $(document).ready(function(){ $('.stars').raty({ score: function() { return $(this).attr('data-score'); } }); }); </script> </head> <body> <b>Star Rating Demo</b> <div class="stars"></div> </body> </html>
Here it is. Our stars will look something like this: Star output rating
First of all, we created a simple HTML document and included JQuery and Raty JS.
Below is the code used to initialize Raty for star rating functionality.
$(document).ready(function(){ $('.stars').raty({ score: function() { return $(this).attr('data-score'); } }); });
Read-only star rating
$('.stars').raty({ readOnly: true });
The number of stars to evaluate $ (". Stars). Raty ({Start: 2});
Functionality Onclick $ (". Stars). Raty ({onClick: function (score) {alert ('Your Score:' + score);}});
Default Cancel Button
$('.stars').raty({ showCancel: true });
Half century display
$('.stars').raty({ showHalf: true });
The user can also retrieve the value of the selected stars and maintain the value in the database using the onclick event. Saty Stars are user-friendly and supported by almost all browsers (Firefox, Google Chrome, Safari, iPad, Iphone, Android Phone, etc.). www.spjoshis.blogspot.com
Gopal joshi
source share