全選,反選
阿新 • • 發佈:2020-11-17
1 //反選、計算 2 function trCheck(id,name,obj){ 3 if($("input[name='check']").length== $("input[name='check']:checked").length){ 4 $("input[name='all-check']").attr("checked",true) 5 } 6 if( $("input[name='check']").length== $("input[name='check']:not(:checked)").length){7 $("input[name='all-check']").attr("checked",false) 8 } 9 if($(obj).attr("checked")=='checked'){ 10 window.parent.getpageName(id,name); 11 }else{ 12 window.parent.remveData(id,name); 13 } 14 }
1 <table class="table table-bordered"> 2 <thead> 3 <tr> 4 <th> 5 <div class="checkbox checkbox-danger"> 6 <input type="checkbox" name="all-check" class="styled" onclick="selectCheck(this)"/> 7 <label class="checkbox-inline"></label> 8 </div> 9 </th> 10 <th>姓名</th> 11 <th>性別</th> 12 <th>手機</th> 13 <th>職務</th> 14 </tr> 15 </thead> 16 <tbody> 17 <c:forEach items="${page.list}" var="voterRegister" varStatus="var"> 18 <tr id="my"> 19 <th scope="row"> 20 <div class="checkbox checkbox-danger"> 21 <input type="checkbox" name="check" value="${voterRegister.id},${voterRegister.name}" onclick="trCheck('${voterRegister.id}','${voterRegister.name}',this)" class="styled" rowid="${voterRegister.id}"/> 22 <label class="checkbox-inline"></label> 23 </div> 24 </th> 25 <%-- <td style="cursor:pointer;" onclick="appendName('${voterRegister.id}','${voterRegister.name}')">${voterRegister.name}</td> 26 <td style="cursor:pointer;" onclick="appendName('${voterRegister.id}','${voterRegister.name}')">${voterRegister.colA}</td> --%> 27 <td style="cursor:pointer;">${voterRegister.name}</td> 28 <td style="cursor:pointer;">${fns:getDictLabels(voterRegister.sex, "sex", "未填寫")}</td> 29 <td>${voterRegister.phone}</td> 30 <td>${voterRegister.occupation}</td> 31 </tr> 32 </c:forEach> 33 </tbody> 34 </table>