js实现checkbox全选和全不选

<%@ page contentType="text/html;charset=UTF-8" language="java" errorPage="/WEB-INF/jsp/error/error.jsp"%>
<%@ include file="/WEB-INF/jsp/common/tagInclude.jsp"%>
<%@ include file="/WEB-INF/jsp/common/declareInclude.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Content-Type" content="text/html;no-cache; charset=UTF-8">
<title>按钮列表</title>


<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/common/css/common.css"/>
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/common/css/keshihua.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/faqi.css" />
  
<script type="text/javascript" src="${pageContext.request.contextPath}/common/jquery/jquery.js"></script>  
<script type="text/javascript" src="${pageContext.request.contextPath}/common/js/common.js"></script>


<script type="text/javascript">
//提交
function saveWin(){
var buttonIds = "";
var buttonNames = "";
var selectButtonOption = "";
$("input[name='butId']").each(function(i,obj){
if($(obj).is(":checked")){
buttonIds += $(obj).attr("value") +";";
buttonNames += $(obj).attr("title") +";";
selectButtonOption += "<option value='"+$(obj).attr("value")+"'>"+$(obj).attr("title")+"</option>";
}
});

if(buttonIds.lastIndexOf(";")>=0){
buttonIds = buttonIds.substring(0,buttonIds.lastIndexOf(";"));
buttonNames = buttonNames.substring(0,buttonNames.lastIndexOf(";"));
}

$("#${param.buttonId}", parent.document).val(buttonIds);
$("#${param.buttonName}", parent.document).val(buttonNames);
var selectButton = "${param.selectButton}";
if(selectButton != undefined && selectButton !=null && selectButton !="" ){
$("#${param.selectButton}", parent.document).html(selectButtonOption);
}
window.parent.portal.close();
}
</script>
<script type="text/javascript">
$(function(){
$("#selectAll").click(function(){
if($(this).is(":checked")){
$("input[name='butId']").each(function(i,obj){
this.checked=true;
});
}else{
$("input[name='butId']").each(function(i,obj){
this.checked=false;
});
}
});

$("input[name='butId']").click(function(){
if($(this).is(":checked")){
}else{
this.checked=false;
}
});

});
</script>
</head>
<body  style="background-color: rgb(255, 255, 255); overflow-x:none; overflow-y:auto;">
<div class="tanchu_con"  >
<div class="ml10 fl" style="overflow-y:auto;overflow-x:hidden; width: 500px; height: 340px;">
<form name="listForm" method="post">
<table class="faqi_tableStyle"style="width: 480px; text-align: left">
<tr >
  <th  class="thStyle" style="text-align: left;">
  <input type="checkbox" id="selectAll" style="margin-left: 10px;">
    </th>
  <th  class="thStyle" style=" text-align: left;">
  <strong>按钮名称</strong>
    </th>
    <th class="thStyle" style="text-align: left;">
  <strong>按钮编码</strong>
    </th>
   </tr>
<c:forEach var="item" items="${buttonList}">
<tr>
<td class="wp70">
  <input type="checkbox" id="butId" name="butId" <c:if test="${item.isChecked eq '1'}">checked='checked'</c:if>
  title="${item.buttonName}" class="ml10" style="margin-top: -5px;" value="${item.id}">
    </td>
  <td class="wp70">
    ${item.buttonName}
    </td>
    <td class="wp70">
    ${item.flag}
    </td>
    </tr>
    </c:forEach>
</table>  
</form>
  </div>
  <p class="width100 mt15 ml10 fl">
  <a class="leader_close btn_white txtc" style="width:200px;margin:0 auto; float: center; cursor: pointer;" οnclick="saveWin();">确认</a>
</p> 
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

starsky20

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值