I'm using jQuery Raty plugin to enable star rating system on my website.
I've a set of 4 ratable questions(can be 5 too) which I display dynamically using a loop. Hence to display the stars I'm using div id as follows:
<c:forEach items="${myQuestionList}" var="singleQuestion" varStatus="status">
<p>${singleQuestion.text}</p>
<div id="star${status.index+1}"></div>
</c:forEach>
And the Raty initialization code is as follows:
$("div[id^=star]").raty({
width: 300
});
This works perfectly fine. All my 4(or 5) questions gets displayed and Raty stars get displayed.
Now the problem is this rating is inside a form & needs to be submitted. But the problem is Raty appends a <input type="hidden" name="score">
to each Raty & hence when the form is submitted, it's impossible to say which rating is for which question.
Is there a way I can assign each Raty hidden input element a different name which will help me relate it with the question asked.
Raty documentation says that I can change the score name to anything:
$('#star').raty({ scoreName: 'myscore' });
But that won't help me coz I'm initializing the raty plugin once for all the elements.
How can I solve this problem? Please guide. I'm stuck. :(