문제

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