CheckBoxList选中某项,获取其它项是否是选中

<div class="formControls col-xs-8 col-sm-9" style="margin-top:-15px;" id="divMarket">
            <span class=" hide">
                              
            </span>
                
                      北美<table id="MainContent_rptMarket_chklRegion_0" class="checkBoxList">
    <tr>
        <td><input id="MainContent_rptMarket_chklRegion_0_0_0" type="checkbox" name="ctl00$MainContent$rptMarket$ctl00$chklRegion$0" value="A1AM78C64UM0Y8" /><label for="MainContent_rptMarket_chklRegion_0_0_0">MX</label></td><td><input id="MainContent_rptMarket_chklRegion_0_1_0" type="checkbox" name="ctl00$MainContent$rptMarket$ctl00$chklRegion$1" value="A2EUQ1WTGCTBG2" /><label for="MainContent_rptMarket_chklRegion_0_1_0">CA</label></td><td><input id="MainContent_rptMarket_chklRegion_0_2_0" type="checkbox" name="ctl00$MainContent$rptMarket$ctl00$chklRegion$2" value="ATVPDKIKX0DER" /><label for="MainContent_rptMarket_chklRegion_0_2_0">US</label></td>
    </tr>
</table><br />
                    
                      欧洲<table id="MainContent_rptMarket_chklRegion_1" class="checkBoxList">
    <tr>
        <td><input id="MainContent_rptMarket_chklRegion_1_0_1" type="checkbox" name="ctl00$MainContent$rptMarket$ctl01$chklRegion$0" value="A13V1IB3VIYZZH" /><label for="MainContent_rptMarket_chklRegion_1_0_1">FR</label></td><td><input id="MainContent_rptMarket_chklRegion_1_1_1" type="checkbox" name="ctl00$MainContent$rptMarket$ctl01$chklRegion$1" value="A1F83G8C2ARO7P" /><label for="MainContent_rptMarket_chklRegion_1_1_1">UK</label></td><td><input id="MainContent_rptMarket_chklRegion_1_2_1" type="checkbox" name="ctl00$MainContent$rptMarket$ctl01$chklRegion$2" value="A1PA6795UKMFR9" /><label for="MainContent_rptMarket_chklRegion_1_2_1">DE</label></td><td><input id="MainContent_rptMarket_chklRegion_1_3_1" type="checkbox" name="ctl00$MainContent$rptMarket$ctl01$chklRegion$3" value="A1RKKUPIHCS9HS" /><label for="MainContent_rptMarket_chklRegion_1_3_1">ES</label></td><td><input id="MainContent_rptMarket_chklRegion_1_4_1" type="checkbox" name="ctl00$MainContent$rptMarket$ctl01$chklRegion$4" value="APJ6JRA9NG5V4" /><label for="MainContent_rptMarket_chklRegion_1_4_1">IT</label></td>
    </tr>
</table><br />
                    
                      日本<table id="MainContent_rptMarket_chklRegion_2" class="checkBoxList">
    <tr>
        <td><input id="MainContent_rptMarket_chklRegion_2_0_2" type="checkbox" name="ctl00$MainContent$rptMarket$ctl02$chklRegion$0" value="A1VC38T7YXB528" /><label for="MainContent_rptMarket_chklRegion_2_0_2">JP</label></td>
    </tr>
</table><br />
                    
                      澳洲<table id="MainContent_rptMarket_chklRegion_3" class="checkBoxList">
    <tr>
        <td><input id="MainContent_rptMarket_chklRegion_3_0_3" type="checkbox" name="ctl00$MainContent$rptMarket$ctl03$chklRegion$0" value="A39IBJ37TRP1C6" /><label for="MainContent_rptMarket_chklRegion_3_0_3">AU</label></td>
    </tr>
</table><br />
                    
                      印度<table id="MainContent_rptMarket_chklRegion_4" class="checkBoxList">
    <tr>
        <td><input id="MainContent_rptMarket_chklRegion_4_0_4" type="checkbox" name="ctl00$MainContent$rptMarket$ctl04$chklRegion$0" value="ATVPDKIKX0DIN" /><label for="MainContent_rptMarket_chklRegion_4_0_4">IN</label></td>
    </tr>
</table><br />
                             
            </div>

 

$(function () {
//当为添加时,站点的设置
var isAdd =<%=ShopId%>;
if (isAdd == 0) {
$("#divMarket").find("input").each(function () {
$(this).click(function () {
var currentTable = $(this).parent().parent().parent().parent();
if (this.checked == true) {//勾选中
$(this).attr("checked", "checked");//选中添加选中属性
var tables = $("#divMarket").find("table");
for (var i = 0; i < tables.length; i++) {
if (currentTable.attr("id") != $(tables[i]).attr("id")) {
$(tables[i]).find("input").attr("disabled", "true");
}
}
} else {//未勾中
$(this).removeAttr("checked");//未选中移除选中属性
var currentTableInputs = $(currentTable).find("input");
var isNoneChecked = 0;
for (var j = 0; j < currentTableInputs.length; j++) {

//注意:如果未添加选中属性与移除属性,$(currentTableInputs[j].attr("checked")取值为一直的defined
if ($(currentTableInputs[j]).attr("checked") == "checked") {
isNoneChecked++;
break;
}
}
if (isNoneChecked == 0) {//没有一个选中,即移除所有禁用
$("input[type='checkbox']").each(function () {
if ($(this).attr("disabled")) $(this).removeAttr("disabled");
});
}
}
});
});
}
});

posted @ 2019-09-27 21:03  enjoryWeb  阅读(619)  评论(0编辑  收藏  举报