如何在检查数组中的另一个时使用jquery取消选中复选框

Hi guys I have a "datatable" with the following checkboxes on it:

<input type="checkbox" name="total_balance[]"  id="total_balance" class="total_balance" value="<?= $balance['supplierID'] ?>" />

<input type="checkbox" name="no_payment[]"  id="no_payment" class="no_payment" value="<?= $balance['supplierID'] ?>" />

That is a loop, so I've hundred of the same names but with different values by row. So what I want is when I check the total_balance[] that has the value=1, for example, it's uncheck, if is checked, the no_payment[] with value=1, and so on.. like if I click the total_balance[] with value=32, uncheck the no_payment with value=32...

How to I do that in jquery??

I've tried like that:

$('input[name="total_balance"]').change(function() {
        console.log(this.value);
        var val = this.value;
        $('input:no_payment[value="' + val + '"]').attr('checked', false);
     });


      $('input[name="no_payment"]').change(function() {
        console.log(this.value);
        var val = this.value;
        $('input:total_balance[value="' + val + '"]').attr('checked', false);
     });

but doesn't work

tks!

查看全部
dongqindu8110
dongqindu8110
2015/02/03 19:25
  • php
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复