tags:

views:

137

answers:

1

Im following a tutorial on this page: http://www.henryhoffman.com/css-star-rating-tutorial.html where the HTML looks like this:

<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>

And the CSS like this:

ul.rating{
background:url(../img/site_img/star.jpg) bottom;
height:21px;
width:115px;
overflow:hidden;
}

ul.rating li{
display:inline
}
.rating a {
display:block;
width:23px;
height:21px;
float:left;
text-indent:-9999px;
position:relative;
}
.rating a:hover {
background:url(../img/site_img/star.jpg) center;
width:115px;
margin-left:-92px;
position:static;
}
.rating a:active {
background-position:top;
}

My problem is that I dont want an a href, I don't want to be transferd to another possition on the page. I just want the the value (1, 2, 3, 4 or 5) to be stored in a label so I can pass that value to the database when I press a button. And if I choose three stars I want three stars to be colured after a pressed the stars and dont hoover the stars anymore.

How can I do that?

A: 

I think you can just change your a hrefs into spans, seeing as the CSS already declared a display:block this should work. Also in CSS change rating a to rating span See if that helps.

<ul class="rating">
<li><span>1</span></li>...

.rating span {
display:block;...
Kyle Sevenoaks
Yes, that works, I dont get transferd. I'm going to try and see how I can save the Span value and how I can make the selection to be colured even if I dont hover the mouse.
Nicklas