You are free to browse all of the content on this site, however if you want to post comments or replies you will need to register for a free account. Becoming a registered member also disables some of the more annoying ads whilst you are logged in.

Javascript

I recently had the need to create a new form element to allow users the ability to select a rating out of 5 for various categories as part of a standard form. There are various ways in which this could be done - radio boxes, select box or a simple text input but my client was fairly set on having a star rating widget. Having looked around on the internet for something to use for this, all I could find was star rating widgets designed to act on their own and not as part of a form. Additionally, none of the solutions would work if javascript was disabled, this left me needing to create on of my own, which I thought I'd share.

Over the last few articles about jQuery, we've shown you how to write plug-ins to encourage reusable code. Sometimes, before writing a plug-in your first step should really be to see if someone else has done it for you.

In the preivious article, we learned how to create a plug-in. In this article we're going to use that pattern to create a dependent selects plug-in.

A dependent select is when a form select box's options depend on the values of a previous form select box. Two examples of this would be a USA State selector, which then filled the next box with cities from that state. Another example would be a car make selector (ie. Ford) which then displayed models (ie. Taurus, Bronco, F-150).
...

In the last article, we learned about the difference between live() and bind() - and when to use them. In this article we're going to put bind() to use and create our first jQuery plug-in.

If you use jQuery, you've heard of its plug-ins - easily reusable bits of code that you can call on selectors like any other jQuery method. What you may not realize is how easy it is to write your own plug-ins, making code reuse in your projects easier then ever.
...