Star Rating Script With YUI
I really needed a nice little star rating system with YUI for this blog (which can been at the bottom) and after a single search in Google I found Ville Saavuori's Star Rating Script for YUI, which is perfect for the job I needed (so you will see a direct implementation of it used here at the bottom of this blog!).
However, for a new project I am undertaking I realised that his implementation was not going to work for multiple rating systems on the same page because it is based on ID's, and as we all know, you can only have one ID reference in the DOM on one page. So I started to rework the script to allow for more rating systems on a single page using classes instead of ID's.
Below I have attached the script as a downloadable zip, which should contain everything you need to get the script working. I have based the script on using an element with the class name 'rating-el', so anything you need the rating system to override, please add that class to the element.
The syntax for creating your rating is as follows:
<div class="ratingdiv"> <a href="#n" title="Average: 3.1" class="rating-el">This will be replaced</a> </div>
As you can see in the example above there is a div surrounding the element we want to be replaced. I haven't tested this but you could probably use a span or any other element as a container here as the script simply looks for the class name. Then, on the element that you want to be replaced by your >rating system simply add the class 'rating-el'. The script will do the work of hiding this element and creating everything it needs to build your rating system.
One thing to note here is that the original example I modified required a form that was hidden, then updated when a rating was clicked and submitted. This method creates a form when a rating is clicked in javascript and sends that instead. This was required in my project because the replaced element had to be an anchor.
Thing may get a little bit messy when it comes to the AJAX calls because I originally implemented quite an advanced system that contained a form and other bits and pieces when the rating was made. If you require a form to be submitted with some extra details I have included a switch in the script that allows this, however, for ease of use the form should be created as a separate file (a simple text version of the form with no other tags or anything) and the path to this needs to be included at the top of the javascript (everything is commented so you will know where to put it). One other other option that is required by the script is the path to send the final rating to so that your server can process it.
Everything is nicely namespaced, so there shouldn't be any conflicts with this and other scripts you may have running
One thing to point out is that in order to get the current average for the item being rated you will need to add a title attribute to the DOM Node you need replacing that contains the exact phrase "Average: x.x": where x.x is the current rating, which will differ for you, obviously. it also requires a decimal place, even if it is 4.0 etc.
I have created a demo page which has a couple of examples, and the script and styles are all in the head of the document in the page. Also there is information on the YUI dependencies you will need, too.
Failing that, if you just want to get a copy, here's one I made earlier, which contains everything you will need to get the script working, including the demo page, which can be used as a reference point to installing the scripts.
Any bugs/feature requests, leave a comment below and enjoy!
Quick update: I have written a tutorials on how you can use MySQL and PHP to build the Star Rating into your site. Just click the following link:
Article Info
- Posted By: Alex Hall
- On: 17th Aug 2009 @ 15:32:55
- Comments: 108
- Rating: 4 / 5
- Hits: 18025
- Listed In: php, javascript, seo
- Short URL: http://bit.ly/hAcve

Author: Chris
#2 | 30th Jun 2011 @ 19:15
Excellent post. I needed a star rating system, I googled for one and found this!
reply
Author: Jens
#3 | 04th Aug 2011 @ 12:44
Thanks for this great information. I was searching for a long time to find something like this.
reply
Author: tim
#5 | 29th Sep 2011 @ 00:01
I could use this script for people to vote on website site designs and give it a certain number of stars!
reply
Author: jalodajohn2
#6 | 16th Nov 2011 @ 06:07
Hi, I'm so excited that I have found this your post because I have been searching for some information about it almost three hours. You helped me a lot indeed and reading this your article I have found many new and useful information about this subject. Thanks for sharing this! cell phone spy
reply
Author: alex
#7 | 30th Sep 2011 @ 13:22
really appreciate your article. This is a great website. I will make sure that I stop back again!.[[Business Marketing|http://www.businesschatter.com.au/marketing]]
reply
Author: Colby Nance
#8 | 10th Oct 2011 @ 12:32
I am a newbie and your success is very much an inspiration for me I would like to reproduced your article, so that more people would see it.
reply
Author: Electronic Cigarette Buy
#9 | 14th Oct 2011 @ 20:37
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: Demir Leather
#10 | 15th Oct 2011 @ 08:28
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: missy
#11 | 20th Nov 2011 @ 06:40
are these scripts really effective and really works for us? PMP boot camps
reply
Author: nishawarner
#12 | 15th Oct 2011 @ 08:59
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information.. Clubmz Reviews
reply
Author: Scrap Metal
#13 | 15th Oct 2011 @ 12:22
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: garage door repair
#14 | 15th Oct 2011 @ 14:58
Entering the promotion of past clients, even if the price of a good efficient design not winning, but winning the additional charge to the customer
reply
Author: lawyer marketing
#15 | 17th Oct 2011 @ 08:27
Just wanted you to know I have added you to my bookmarks. I've seen your other blog topics too and I think you've got great ideas. Keep it going!
reply
Author: seragam sekolah
#16 | 17th Oct 2011 @ 09:54
I agree with your conclusions and will eagerly look forward to your incoming updates. Just saying thanks will not just be adequate, for the wonderful clarity in your writing.It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing seragam sekolah pupuk organik
reply
Author: what is roth ira
#17 | 19th Oct 2011 @ 05:47
a first step in protecting consumers from industry practices that can keep them mired in credit card debt despite their best efforts to dig themselves out.
reply
Author: lyn cayce
#18 | 19th Oct 2011 @ 10:05
I am definitely tired of struggling to find relevant and intelligent commentary on this subject. Everyone nowadays seem to go to extremes to either drive home their viewpoint or suggest that everybody else in the globe is wrong.Thank you for taking your time sharing this to you readers. christmas gifts 2011
reply
Author: SEO UK
#19 | 19th Oct 2011 @ 11:49
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: makeityourring diamond engagement rings
#20 | 20th Oct 2011 @ 13:55
wow ... This article is very nice, and I think your article worth reading public. I would like to see more helpful reply post in your blog.
reply
Author: UK SEO
#21 | 21st Oct 2011 @ 08:13
This method creates a form when a rating is clicked in javascript and sends that instead. This was required in my project because the replaced element had to be an anchor.
reply
Author: SEO UK
#22 | 21st Oct 2011 @ 10:03
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: best toilet
#23 | 21st Oct 2011 @ 15:56
I also found the same problem with you. So apparently this is just a false warning. I think, that my computer has really got a virus.
reply
Author: cigarettes electronic
#24 | 22nd Oct 2011 @ 13:50
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: Christian Web Design
#25 | 23rd Oct 2011 @ 16:47
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: brendamya
#26 | 23rd Oct 2011 @ 20:45
This short article truly impressed me. I had been searching some good info. phen375
reply
Author: Generic Viagra Online
#27 | 24th Oct 2011 @ 13:40
I found your blog very interesting and very informative..
reply
Author: Christian Web Design
#28 | 24th Oct 2011 @ 13:49
This was required in my project because the replaced element had to be an anchor.
reply
reply
Author: Billig tandblekning
#29 | 25th Oct 2011 @ 04:53
I would like to thank you for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own blog now.
reply
Author: ekg technician
#30 | 25th Oct 2011 @ 08:10
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: bolsas reutilizables fabricante
#31 | 26th Oct 2011 @ 07:47
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: medical billing and coding
#32 | 26th Oct 2011 @ 11:03
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: pasadena electricians
#33 | 31st Oct 2011 @ 22:25
what a cool article. thanks for the info. good looking out. loved the middle part.
reply
Author: seo
#34 | 02nd Nov 2011 @ 11:56
In fact your creative writing abilities has inspired me to start my own blog now.
reply
Author: pitons
#35 | 02nd Nov 2011 @ 12:45
se glisser parmi les infographistes-figurants.
reply
Author: Cotton bay village
#36 | 02nd Nov 2011 @ 15:17
This method creates a form when a rating is clicked in javascript and sends that instead. This was required in my project because the replaced element had to be an anchor.
reply
Author: 2011 genesis coupe
#37 | 02nd Nov 2011 @ 15:52
This is the best blog for anybody who needs to seek out out about this topic. You realize so much its virtually hard to argue with you. You definitely put a new spin on a topic that's been written about for years.
reply
Author: Productivity
#38 | 03rd Nov 2011 @ 16:20
A free hop on hop off bus with on-board entertainment taking you to some of Light Night's hotspots.
reply
Author: business franchise
#39 | 04th Nov 2011 @ 16:43
It is extremely helpful for me. would you mind updating your blog with more information
reply
Author: M.P.Solutions Direct
#40 | 05th Nov 2011 @ 11:11
I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. I enjoyed every little bit part of it and I will be waiting for the new updates. SD Acquisitions | SMS Worldwide
reply
Author: franchise opportunity
#41 | 06th Nov 2011 @ 08:31
This method creates a form when a rating is clicked in javascript and sends that instead. This was required in my project because the replaced element had to be an anchor.
reply
Author: business for sale melbourne
#42 | 06th Nov 2011 @ 09:38
This method creates a form when a rating is clicked in javascript and sends that instead. This was required in my project because the replaced element had to be an anchor.
reply
Author: dentist in thailand
#43 | 06th Nov 2011 @ 16:29
Thanks for the informative post, you've certainly raised some valid points, I'm going to bookmark your blog!dentist in thailand
reply
Author: Fisher Investments Careers
#44 | 08th Nov 2011 @ 03:48
It has been seen for a couple of years that liver disease is spreading a lot.I think the main thing is the level of fats increases inside the body which will effect the lever Fisher Investments Careers
reply
Author: Alaine
#45 | 08th Nov 2011 @ 05:13
Great script. An excellent read both informational and enriching. Thanks.
Electronic Cigarette
reply
Author: Workout Routines to Build Muscle
#46 | 08th Nov 2011 @ 05:34
The Internet is all about the flow of free information. There are millions of sites on the web and they are all looking for new content to keep their visitors coming back. This is where articles and article directories come inWorkout Routines to Build Muscle
reply
Author: Android app developer
#47 | 08th Nov 2011 @ 08:02
I have gained some useful information from this site. Thanks for sharing this information.I just wanted to leave a comment as a token of appreciation.
reply
Author: top ab workouts for men
#48 | 08th Nov 2011 @ 10:25
Wonderful post! This is very useful to many readers like me. Being a student, I am requiring myself to read articles more often and your writing just caught my interest. Thank you so much!top ab workouts for men
reply
Author: wow leveling guide
#49 | 09th Nov 2011 @ 07:08
Commenting on this site is a pleasure for me. I had really liked reading this site it was very good. The content of this blog was very nice. Like it! wow leveling guide
reply
Author: mobile marketing
#50 | 10th Nov 2011 @ 03:01
I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful mobile marketing
reply
Author: executive coaching
#51 | 10th Nov 2011 @ 06:45
Thank you for posting the great contentâ¦I was looking for something like thisâ¦I found it quiet interesting, hopefully you will keep posting such blogsâ¦.Keep sharing
reply
Author: roman blinds
#52 | 10th Nov 2011 @ 11:10
E vožnja jer dosta ugodna, ne osjetiÅ¡ baÅ¡ neki napor, motor te svako malo pogura, vjerojatno zgodno za vožnju po gradu i Å¡to se baterije tiÄe dosta ekonomiÄnije.
reply
Author: appliances
#53 | 10th Nov 2011 @ 16:59
Very helpful, This post give truly quality information. You made some exceptional points and I am grateful for your insight! appliances
reply
Author: best juice extractor
#54 | 11th Nov 2011 @ 07:06
It's culture after hours for all ages, so start planning your Light Night and get those invitations to your friends and family to join you for this special spring festival.
reply
Author: AnnaNguyen09
#55 | 11th Nov 2011 @ 14:17
Completely understand what your stance in this matter. Although I would disagree on some of the finer details, I think you did an awesome job explaining it. Sure beats having to research it on my own. Thanks
reply
Author: medical billing
#56 | 11th Nov 2011 @ 14:37
This was required in my project because the replaced element had to be an anchor.
reply
Author: Buy Facebook Fans
#57 | 12th Nov 2011 @ 04:01
Recently Iâve run into a piece of class which was operating as the central place for type conversions in the system. While the idea of having such a class doesnât sound like a problem, the way itâs been implemented definitely is. Buy Facebook Fans
reply
Author: Malaysia Online Boutique
#58 | 12th Nov 2011 @ 09:11
Iâd would like to thank you for visiting my vapor cigarette information site.I know that youâll benefit from all the information on the vapor cigarette. I have done a lot of research about the electronic cigarette and my goal is to help you make an informed decision about this product.
reply
Author: fonts for tattoos
#59 | 13th Nov 2011 @ 08:39
Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.fonts for tattoos
reply
Author: payday loans online
#60 | 13th Nov 2011 @ 11:13
I have a presentation incoming week, and I am on the lookout for such information
reply
Author: cabelas coupon
#61 | 13th Nov 2011 @ 13:55
As a new version of the application, this is a good way to sharing the guide of using it cabelas coupon
reply
Author: Digital Agency Florida
#62 | 13th Nov 2011 @ 18:55
The script will do the work of hiding this element and creating everything it needs to build your rating system.
reply
Author: judy
#63 | 14th Nov 2011 @ 06:19
wow.. I am now learning a lot from the script. that's good. diets that work fast
reply
Author: cheap car insurance
#64 | 14th Nov 2011 @ 08:18
In order for us to make this as easy as possible for you, as well as our commenting system on all articles and tools
reply
Author: memory foam beds
#65 | 14th Nov 2011 @ 22:58
Some folks has a room for his or her passion. Some folks will create a mini cinema. They can design a dead ringer for the actual cinema. memory foam beds
reply
Author: Sharelord Advanced
#66 | 15th Nov 2011 @ 05:45
Well written article. I completely agreed to above comment, your instructions are very appreciable.
reply
Author: medical billing and coding schools
#67 | 15th Nov 2011 @ 10:25
Star Rating Script With YUI :: Website Development and SEO..
reply
Author: Mobile Application Development
#68 | 15th Nov 2011 @ 10:49
I realised that his implementation was not going to work for multiple rating systems on the same page because it is based on ID's, and as we all know, you can only have one ID reference in the DOM on one page Mobile Application Development
reply
Author: kamagra
#69 | 17th Nov 2011 @ 07:20
Hey,WOw!!You created wonderful site..I like designing part of this site..amazing layout used to create this site..good work!!
reply
Author: Flat management
#70 | 17th Nov 2011 @ 09:49
This is a wonderful rating Idea. Keep it up! Flat management
reply
Author: family daycare
#71 | 17th Nov 2011 @ 11:32
Took me time to read all the comments, but I really enjoyed the article. It proved to be very helpful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also engaged! I'm sure you had joy writing this article.
reply
Author: Digital Agency Orlando
#72 | 17th Nov 2011 @ 11:39
which can be used as a reference point to installing the scripts.
reply
Author: ban terbaik di Indonesia gt radial
#73 | 17th Nov 2011 @ 21:47
my blog not work wtih yui, how this?
reply
Author: Century 21 Broker Properti Jual Beli Sewa Rumah Indonesia
#74 | 17th Nov 2011 @ 21:48
like to me.. how this?
reply
Author: Xlangkah lebih maju
#75 | 17th Nov 2011 @ 21:49
where is the owner this site? please give the advice.. thanks
reply
Author: klebeband bedrucken
#76 | 18th Nov 2011 @ 05:04
I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful klebeband bedrucken
reply
Author: home depot printable coupons
#77 | 18th Nov 2011 @ 13:08
but it really compensated for my time. I will post a link to this page on my blog.
reply
Author: jesikaomi
#78 | 18th Nov 2011 @ 14:22
You can contact with a good web developer near to you. He can give you an idea about this. I want to make this easy to you. Just contact with a professional. You can get tutorial in internet. But you can not learn much from them without helping hand. dentist in austin
reply
Author: mivcon
#79 | 18th Nov 2011 @ 17:45
this great information. I was searching for a long time to find something like this. sydney furniture
reply
Author: saima
#80 | 19th Nov 2011 @ 07:33
its wonderful post here. it has so many things for us. please share your views. Internet Marketing Strategies
reply
Author: Frugal Tips
#81 | 19th Nov 2011 @ 07:35
Is this script really works? Can you please tell us the procedure of this - Frugal Tips
reply
Author: jsmith
#82 | 19th Nov 2011 @ 12:35
The script will do the work of hiding this element and creating everything it needs to build your rating system.
arrest warrants
warrants for arrest
warrant search
reply
Author: Samsung Galaxy Note Unlock
#83 | 19th Nov 2011 @ 14:21
I require is that you sign up for an API key (which is free and easy to do too!) Samsung Galaxy Note Unlock
reply
Author: aarenace jack
#84 | 19th Nov 2011 @ 18:54
its wonderful post here. web design Melbourne
reply
Author: deer antler velvet
#85 | 20th Nov 2011 @ 00:12
good written article. keep posting for more ideas and thoughts. deer antler velvet
reply
Author: Industrial flooring
#86 | 20th Nov 2011 @ 05:47
I really like following your blog as the articles are so simple to read and follow. Excellent. Please keep up the good workIndustrial flooring
reply
Author: voodoo knife block
#87 | 20th Nov 2011 @ 08:28
good written article. keep posting for more ideas and thoughts.voodoo knife block
reply
Author: Bellla
#88 | 20th Nov 2011 @ 09:09
I say May very well in no way long been on that blog page through a long while nevertheless it really was basically contentment to search out it again ever again. It happens to be this fundamental content not to mention forgotten from a multitude of perhaps even gurus! I just regards for the purpose of leaving families further receptive to such factors. Solely amazing items per customary!Portuguese Translation
reply
Author: Motorcycle Jackets
#89 | 21st Nov 2011 @ 06:15
I haven't tested this but you could probably use a span or any other element as a container here as the script simply looks for the class name. Then, on the element that you want to be replaced by your >rating system simply add the class 'rating-el'. The script will do the work of hiding this element and creating everything it needs to build your rating system. Motorcycle Boots
reply
Author: Plumber harpenden
#90 | 21st Nov 2011 @ 07:38
Awesome post.Having a lot of information,s.I book mark this post for future reference.Plumber harpenden
reply
Author: Credit Card Merchant Account
#91 | 21st Nov 2011 @ 10:41
Signals mainly acquire to arise from the western allocation of Russia. Credit Card Merchant Account
reply
Author: Buyers Agent
#92 | 21st Nov 2011 @ 10:46
I read you blog and get some tips from it That how to improve the Seo work . Thanks for sharing.
reply
Author: how to get ripped fast
#93 | 21st Nov 2011 @ 18:12
I have gained some useful information from this site. Thanks for sharing this information.how to get ripped fast
reply
Author: Soup Diet
#94 | 22nd Nov 2011 @ 12:38
Pretty insightful publish. Never believed that it was this simple after all. I had spent a good deal of my time looking for someone to explain this subject clearly and youâre the only one that ever did that. Keep it up
reply
Author: Joshua
#95 | 23rd Nov 2011 @ 14:54
A great information. thanks for the share.
upholstery cleaning Canberra
reply
Author: boom
#96 | 24th Nov 2011 @ 06:37
This is a spectacular article that I have really enjoyed. Hopefully I can learn more from your valuable experience. Thanks a lot for sharing this and please keep on posting more.Canon Digital SLRs
reply
Author: Real Estate Sydney
#97 | 24th Nov 2011 @ 07:27
Which kind of new project you are going to take? Will you please share some more updates with all - Real Estate Sydney
reply
Author: best baby carriers
#98 | 24th Nov 2011 @ 09:31
I had really liked reading this site it was very good. The content of this blog was very nice.
reply
Author: Business courses
#99 | 24th Nov 2011 @ 10:03
Thanks for taking the time to talk about this, I feel fervently about this and I take pleasure in learning about this topic. Please, as you gain information, please update this blog with more information. I have found it very useful. There have to be charging stations everywhere.
reply
Author: Brisbane Landscaper
#100 | 24th Nov 2011 @ 10:32
What a great and useful information your put here! I was searching this blog for many days. Now I am very happy to find this blog. Thanks for put this blog here.
reply
Author: ianjark
#101 | 24th Nov 2011 @ 11:00
I feel you are too good to write Genius!Thanks for posting, maybe we can see more on this blog in future.UK University Essays Help
reply
Author: electronic cigarette
#102 | 24th Nov 2011 @ 12:45
Nice informative post and its good resourceful for lots of Internet users. Because most of they needed these kinds of blog to improve the knowledge. so your blog is useful to those peopleelectronic cigarette
reply
Author: best espresso makers
#103 | 24th Nov 2011 @ 12:54
Also there is information on the YUI dependencies you will need, too.
reply
Author: wine coolers reviews
#104 | 24th Nov 2011 @ 14:29
One other other option that is required by the script is the path to send the final rating to so that your server can process it.
reply
Author: Blinds
#105 | 25th Nov 2011 @ 07:33
Your writing style is unique; it has helped me understand about internet user more clearly. Thank you. Blinds
reply
Author: Blinds
#106 | 25th Nov 2011 @ 07:34
I enjoyed this site. Itâs an informative topic. It helps me very much to solve some problems.
Blinds
reply
Author: Building Inspections Gold Coast
#107 | 25th Nov 2011 @ 08:47
I always wanted to know more about scripted YUI. Have you been interested in YUI for long? Building Inspections Gold Coast
reply
Author: Pergolas Sydney
#108 | 25th Nov 2011 @ 10:35
Keep blogging about this script, you are doing a wonderful job. Pergolas Sydney
reply