jquery 的过滤器函数怎么写啊?

wenwen1 发布于 2013/01/04 17:46
阅读 259
收藏 0

【华为云1024程序员节·向云而生】预约直播 抽14件华为电子产品礼包!>>>

<%@page language="java" isELIgnored="false" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<jsp:directive.include file="/WEB-INF/sitemesh-decorators/include.jsp"/>
<fmt:setBundle basename="bundles.project-resources"/>
<html>
<head>
<meta name="decorator" content="iframe"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
//-------------------------------------列表排序------------------------------------
$(document).ready(function() {
  $("table").tablesorter({
         headers: {
            3: {
                 sorter: false
             }
         }
     });
    //-------------------------------------结束------------------------------------
});
function test(i,checkbox) { 
  var str="one"+i;
  $("#"+str+":"+'input[type=checkbox]').prop('checked', $(checkbox).prop('checked'));
         }
</script>
<style>
  p { margin: 8px; font-size:16px; }
  .selected { color:blue; }
  .highlight { background:yellow; }
  </style>

</head>
<body>
<div id="contentarea">   
 <div id="content">
 <form:form action="${pageContext.request.contextPath}/saveNewProjectMember" method="POST" modelAttribute="user">
  <form:hidden path="CDegree.id" value="${project.id}"/>
  <form:hidden path="CGender.id" value="2"/>
  <table cellpadding="0" cellspacing="0" id="viewTable" class="tablesorter">
    <thead>
     <tr>
     <th  width="10%"><fmt:message key="projectmember.department.title"/></th>
     <th  width="85%"><fmt:message key="projectmember.userid.title"/></th>
     <th  width="5%"><fmt:message key="operation"/></th>
     </tr>
    </thead>
    <tbody>
     <c:forEach items="${departments}" var="current"  varStatus="i"> 
      <c:choose>
       <c:when test="${(i.count) % 2 == 0}">
           <c:set var="rowclass" value="rowtwo"/>
       </c:when>
       <c:otherwise>
           <c:set var="rowclass" value="rowone"/>
       </c:otherwise>
      </c:choose>
     <tr class="${rowclass}">
      <td>
       ${current.name}
      &nbsp;
      </td>
      <td id="one${current.id}">      
         <c:forEach items="${current.users}" var="user"  varStatus="j">
          <form:checkbox path="userName" value="${user.id}" />${user.cname}&nbsp;
         </c:forEach>                 
      </td>
      <td>
      <input type="checkbox" onclick="test('${current.id}',this);"/>全选
      </td>
     </tr>
     </c:forEach>
    </tbody>
   </table>
   <span class="inputbutton"><input class="savebutton" id="save" type="submit" value="<fmt:message key="navigation.save"/>"/></span>
   <script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'save', event:'onclick'}));</script>
   </form:form>
  <div class="clear">&nbsp;</div>
 </div>
</div>
</body>
</html>

我想要的效果是点击一个tr后面的全选,让这个tr中的checkbox都全选,我想问下function test(i,checkbox) { 
  var str="one"+i;
  $("#"+str+":"+'input[type=checkbox]').prop('checked', $(checkbox).prop('checked'));
         }

这个函数该怎么改?

加载中
0
iSea
iSea
代码好好排版一下哦,看着头晕
返回顶部
顶部