I have a checkbox group and I need to get the checkbox that the user clicked, so I need to manipulate the others that are from the same group.
<input type="checkbox" name="grupo[1][1][]" value="A" data-unique="0"> A
<input type="checkbox" name="grupo[1][2][]" value="B" data-unique="0"> B
<input type="checkbox" name="grupo[1][3][]" value="C" data-unique="0"> C
<input type="checkbox" name="grupo[1][4][]" value="D" data-unique="1"> D
<input type="checkbox" name="grupo[2][1][]" value="A" data-unique="0"> A
<input type="checkbox" name="grupo[2][2][]" value="B" data-unique="0"> B
<input type="checkbox" name="grupo[2][3][]" value="C" data-unique="0"> C
<input type="checkbox" name="grupo[2][4][]" value="D" data-unique="1"> D
In another checkbox listing I have done so:
$('input[name="grupo[]"]').click(function() {
var $this = $(this);
var is_unique = $this.data('unique');
var is_checked = $this.is(':checked');
var grupo = $('input[name="grupo[]"]');
if(is_unique == '1') {
grupo.each(function() {
$(this).prop("checked", false);
$(this).prop("disabled", is_checked);
$this.prop("checked", is_checked);
$this.prop("disabled", false);
});
}
});
In my new listing I have this multidimensional array and that way it does not work, does anyone have any tips to help me?