I've seen a tutorial online - http://www.htmldrive.net/items/show/402/CSS-Star-Rating-System - for making a CSS star rating system.
On the page they have this code:
<ul class="rating">
<li><a href="#" title="1 Star">1</a></li>
<li><a href="#" title="2 Stars">2</a></li>
<li><a href="#" title="3 Stars">3</a></li>
<li><a href="#" title="4 Stars">4</a></li>
<li><a href="#" title="5 Stars">5</a></li>
</ul>
From what I can tell, this is just a list. How would I integrate it into my form, so that the information from the star rating can be submitted to a database. My current code for the form is below:
<p>Quality</p>
<input type="radio" name="ratingquality" value="1">
<input type="radio" name="ratingquality" value="2">
<input type="radio" name="ratingquality" value="3">
<input type="radio" name="ratingquality" value="4">
<input type="radio" name="ratingquality" value="5">
CSS:
HTML:
This is very easy to use, just copy-paste the code. You can use your own star image in background.
I have created a variable
var userRating
. you can use this variable to get value from stars.Enjoy!! :)
I'm going to say right off the bat that you will not be able to achieve the look they have with radio buttons with strictly CSS.
You could, however, stick to the list style in the example you posted and replace the
anchors
with clickablespans
that would trigger a javascript event that would in turn save that rating to your database via ajax.If you went that route you would probably also want to save a cookie to the users machine so that they could not submit over and over again to your database. That would prevent them from submitting more than once at least until they deleted their cookies.
But of course there are many ways to address this problem. This is just one of them. Hope that helps.
How about this? I needed the exact same thing, I had to create one from scratch. It's PURE CSS, and works in IE9+ Feel-free to improve upon it.
Demo: http://www.d-k-j.com/Articles/Web_Development/Pure_CSS_5_Star_Rating_System_with_Radios/
CSS:
Here is the solution.
The HTML:
The CSS:
Hope this helps.
Source
Here is how to integrate CSS star rating into an HTML form without using javascript (only html and css):
CSS:
HTML:
Please check the demo