Here is a simple star rating javascript we use for our support incident ratings:
<script>
freeze = 0;
hasRated = false;
function point_it(event,freezeit){
pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("rating_image").offsetLeft;
pos_x = Math.round(pos_x/14)*14;
document.getElementById('rating_gradient').style.width = pos_x+"px";
if (freezeit) {
hasRated = true;
freeze = pos_x;
document.getElementById('hiddenRating').value = pos_x/28;
document.getElementById('RatingText').innerHTML = 'Current rating: <str' +'ong>'+(pos_x / 28)+'<\/strong>\/ 5';
}
}
function returntofreeze(){
document.getElementById('rating_gradient').style.width = freeze+"px";
}
</script>
How would you rate this?
<br />
<div id="rating_image" style="position:absolute"><img src="http://www.webassist.com/images/star_cutout.gif" width="140" height="28" alt="rating" onmousemove="point_it(event)" onclick="point_it(event,true)" onmouseout="returntofreeze()"/></div>
<div id="rating_gradient" style="width:0px;overflow:hidden;display:block;"><img src="http://www.webassist.com/images/star_gradient.jpg" width="140" height="28" /></div>
<input name="hiddenRating" type="hidden" id="hiddenRating" value="0" />
<div id="RatingText">Current rating: <strong>0</strong>/5</div>
You can probably just cut and paste it onto a form on your page and use the hidden form element to insert into a database or whatever else.