Connecting Tech Pros Worldwide Forums | Help | Site Map

star rating system

pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 424
#1: Oct 26 '09
I have a small problem . I want to build a rating system where in a user rates 5-6 features of a product . i don't want to update the server database on each click of the product feature but after he has done with all the feature rating he should be able to submit!!! i have problem in generating this stars ...i need to highlight say 1-3 stars when 3rd star is clicked and how do i pass the value when updating .... i use php as server side scripting!!!!

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,592
#2: Oct 26 '09

re: star rating system


The first problem is the highlighting. When one is clicked, loop over the stars to change the image src property until it reaches the clicked one, e.g.:
Expand|Select|Wrap|Line Numbers
  1. for (i = 0; i < num; i++) {
  2.     document.getElementById("feature1star"+i).src = '...';
  3. }
pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 424
#3: Oct 26 '09

re: star rating system


you mean to say change the class so as to make it highlighted !!!

second problem how will i set a value for each star and pas sit through the form ?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,592
#4: Oct 26 '09

re: star rating system


Well, change the class or the image source, whatever suits you. Have two images: one normal (blank star) and one highlighted.

To pass the value, it depends on your server-side script. However, you only need to pass 5/6 values and all of them will be numbers, so, for example:
Expand|Select|Wrap|Line Numbers
  1. "url.php?feature1="+encodeURIComponent(feature1rating) + ...
and so on.
pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 424
#5: 3 Weeks Ago

re: star rating system


http://www.fyneworks.com/jquery/star.../#tab-Overview


I found this jquery plugin useful.
Reply