You are currently browsing the tag archive for the 'rating system' tag.
Tag Archive
Ajax Star Rating System
March 28, 2008 in Development Tips, Tutorials | Tags: ajax, rating system | Leave a comment
Have yet to try this out on any of my websites but think it would be very neat to include on any real estate or e commerce website.
——————————–
AJAX Rating Stars Demo
Examples
Simple form binding |
|
|
var s1 = new Stars({ maxRating: 5, bindField: ‘myRating’, imagePath: ‘images/’, value: 4.5 }); |
<script type="text/javascript">
var s1 = new Stars({
maxRating: 5,
bindField: 'myRating',
imagePath: 'images/',
value: 4.5
});
</script>
|
JavaScript callback function |
|
function rating(val) { alert(‘You rated it ‘ + val + ‘ star(s)!’); } var s2 = new Stars({ maxRating: 5, imagePath: ‘images/’, callback: rating }); ![]() ![]() ![]() ![]() ![]() |
<script type="text/javascript">
function rating(val)
{
alert('You rated it ' + val + ' star(s)!');
}
var s2 = new Stars({
maxRating: 5,
imagePath: 'images/',
callback: rating
});
</script>
|
Sending values through AJAX |
|
function ajaxRating(xml) { var x = xml.responseXML; var xmlRating = x.getElementsByTagName(‘rating’); var rating = xmlRating[0].firstChild.nodeValue; alert(‘You rated it ‘ + rating + ‘ star(s)!’); } var s3 = new Stars({ maxRating: 5, actionURL: ‘rate.php?rating=’, callback: ajaxRating, imagePath: ‘images/’, value: 3 }); ![]() ![]() ![]() ![]() ![]() |
<script type="text/javascript">
function ajaxRating(xml)
{
var x = xml.responseXML;
var xmlRating = x.getElementsByTagName('rating');
var rating = xmlRating[0].firstChild.nodeValue;
alert('You rated it ' + rating + ' star(s)!');
}
var s3 = new Stars({
maxRating: 5,
actionURL: 'rate.php?rating=',
callback: ajaxRating,
imagePath: 'images/',
value: 3
});
</script>
|
Read more at: http://www.beauscott.com/examples/RatingStars/




