我使用jquery.rating.js来评估我的网络应用中的功能。当我在列表视图中使用此评级工具时,评级值未获得正确的值。每当我点击评级时,它将添加到之前的评级。
< link rel = stylesheet type = "text/css"
href = "jquery.rating.css" >
< script src = "jquery.form.js" > < /script>
<script src="jquery.js"></script >
< script src = "jquery.MetaData.js" > < /script>
<script src="jquery.rating.js"></script >
< script src = "jquery.rating.pack.js" > < /script>
<script language="javascript">
$( document ).ready(function() {
$(".auto-submit-star").rating({ callback: function(value, url){
var rating = $('.star-rating-control .star-rating-on').length;
var name = this.name;
var pid = name.substring(0, name.length - 1);
var username = document.getElementById("username").innerHTML;
var prating = document.getElementById("pRating").innerHTML;
document.getElementById("pRating").innerHTML = rating;
alert(rating);
alert(prating);
rating = Math.abs(rating - prating);
$.get("/StrutsBlog / rating.do ? rating = "+rating+" & pid = "+pid+" & username = "+username, function(data, status){
});
} });
});
</script>
&#13;
</TR>
<% int j=0; java.util.List<PostBean>pbeanList = (java.util.List
<PostBean>) request .getAttribute("postlist"); System.out.println("postlist" + pbeanList); for (PostBean pbean : pbeanList) { %>
<tr>
<td bgcolor="#f0e6d5" colspan="2"></td>
</tr>
<TR bgcolor="#f0e6d5">
<TD width="18%" valign="top">
<FONT SIZE="2" face="Verdana, Arial" color="#000000"><B>
<%=pbean.getPostby()%>
</B></font>
<BR>Member #
</FONT>
</TD>
<TD>
<img src="http://saloon.javaranch.com/ubb/posticon.gif" border="0">
<FONT SIZE="1" color="#800080" face="Verdana, Arial" color="#000000">
posted
</FONT>
<HR size="1" color="#dedfdf">
<FONT SIZE="2" FACE="Verdana, Arial" color="#000000">
<%=pbean.getPostdesc()%>
</FONT>
<a><img src="fetchpostimage.do?postid=<%=pbean.getPostid()%>" width="50" height="50"/></a>
<HR size="1" color="#dedfdf">
<FONT SIZE="1" face="Verdana, Arial" color="#000000">
Postedon:<%=pbean.getPostedon()%>
| <a href="deletepost.do?tid=<%=request.getParameter("tid")%>&pid=<%=pbean.getPostid()%>"><img title="Remove" alt="Remove" src="images/thrash.png"/></a>
<a href="editPost.jsp?tid=<%=request.getParameter("tid")%>&pid=<%=pbean.getPostid()%>&description= <%=pbean.getPostdesc()%>"><img title="Edit" alt="Edit" src="images/edit-icon.png"/></a>
<input name="<%=pbean.getPostid()%><%=j %>" type="radio" class="auto-submit-star"/>
<input name="<%=pbean.getPostid()%><%=j %>" type="radio" class="auto-submit-star"/>
<input name="<%=pbean.getPostid()%><%=j %>" type="radio" class="auto-submit-star" checked="checked"/>
<input name="<%=pbean.getPostid()%><%=j %>" type="radio" class="auto-submit-star"/>
<input name="<%=pbean.getPostid()%><%=j %>" type="radio" class="auto-submit-star"/>
</FONT>
</td>
</tr>
<%j++;} %>
&#13;
请帮帮我..