Question

I'm trying to have a rating system using radio buttons in JSP ...Everything is working just fine .. but i need to represent an integer as stars... for example if the value is 2.. the JSP page should return 2 stars out of five... etc..

    <div id="rate1">

        <input type="radio" name="rating" value="1" class="star">
        <input type="radio" name="rating" value="2" class="star">
        <input type="radio" name="rating" value="3" class="star">
        <input type="radio" name="rating" value="4" class="star">
        <input type="radio" name="rating" value="5" class="star">
    </div>

    rating = <%= request.getAttribute("Result") %>

i'm getting the value from a servlet...

i found a hint on a website

$().rating('select', index / value) Use this method to set the value (and display) of the star rating control via javascript. It accepts the index of the star you want to select (0 based) or its value (which must be passed as a string.

but i'm really bad in Javascript... I dunno how to do this..

Can anyone help ?!

Was it helpful?

Solution

$("input[name='rating']").rating('select',rating);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top