star rating system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    star rating system

    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
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.:
    Code:
    for (i = 0; i < num; i++) {
        document.getElementById("feature1star"+i).src = '...';
    }

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      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 ?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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:
        Code:
        "url.php?feature1="+encodeURIComponent(feature1rating) + ...
        and so on.

        Comment

        • pradeepjain
          Contributor
          • Jul 2007
          • 563

          #5
          jQuery Star Rating Plugin. Contribute to fyneworks/star-rating development by creating an account on GitHub.



          I found this jquery plugin useful.

          Comment

          Working...