Star Rating Using Select Dropdown Box
by bizamajig
HTML
<link rel="stylesheet" href="http://www.jhwebdesigner.com/rating-system/rating-system/rating_simple.css">
<select name="my_input" id="rating_simple">
<option value="0" selected="selected"></option>
<option value="1">Poor</option>
<option value="2">Below Average</option>
<option value="3">Average</option>
<option value="4">Good</option>
<option value="5">Excellent</option>
</select>
JavaScript
(function (a) {
a.fn.webwidget_rating_simple = function (p) {
var p = p || {};
var b = p && p.rating_star_length ? p.rating_star_length : "5";
var c = p && p.rating_function_name ? p.rating_function_name : "";
var e = p && p.rating_initial_value ? p.rating_initial_value : "";
var d = p && p.directory ? p.directory : "images";
var f = "";
var g = a(this);
b = parseInt(b);
init();
g.next("ul").children("li").hover(function () {
$(this).parent().children("li").css('background-image', 'url(http://www.jhwebdesigner.com/rating-system/rating-system//nst.gif)');
var a = $(this).parent().children("li").index($(this));
$(this).parent().children("li").slice(0, a + 1).css('background-image', 'url(http://www.jhwebdesigner.com/rating-system/rating-system//sth.gif)')
}, function () {});
g.next("ul").children("li").click(function () {
var a = $(this).parent().children("li").index($(this));
f = a + 1;
g.val(f);
if (c != "") {
eval(c + "(" + g.val() + ")")
}
});
g.next("ul").hover(function () {}, function () {
if (f == "") {
$(this).children("li").css('background-image', 'url(http://www.jhwebdesigner.com/rating-system/rating-system//nst.gif)')
} else {
$(this).children("li").css('background-image', 'url(http://www.jhwebdesigner.com/rating-system/rating-system//nst.gif)');
$(this).children("li").slice(0, f).css('background-image', 'url(http://www.jhwebdesigner.com/rating-system/rating-system//sth.gif)')
}
});
function init() {
$('<div style="clear:both;"></div>').insertAfter(g);
g.css("float", "left");
var a = $("<ul>");
a.attr("class", "webwidget_rating_simple");
for (var i = 1; i <= b; i++) {
...