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

有帮助吗?

解决方案

$("input[name='rating']").rating('select',rating);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top