2
<tr>
    <td>
        <input type="checkbox" value="14292" name="chec_emp[]" class="chec_emp">
    </td>
    <td>Test User One</td>
    <td>Autobot</td>
    <td>Shadow</td>
    <td>50</td>
</tr>

<tr>
    <td>
        <input type="checkbox" value="14293" name="chec_emp[]" class="chec_emp">
    </td>
    <td>Test User One</td>
    <td>Autobot</td>
    <td>Billed</td>
    <td>50</td>
</tr>

<tr>
    <td>
        <input type="checkbox" value="14292" name="chec_emp[]" class="chec_emp">
    </td>
    <td>Test User Two</td>
    <td>Autobot</td>
    <td>Billed</td>
    <td>50</td>
</tr>

To disable checkbox with duplicate value, following code is used

$('.chec_emp').each(function(){
    if ($(this).is(':enabled')) {
        $('.chec_emp[value="'+$(this).val()+'"]').not(this).prop('disabled', 'disabled');
    }
});

But the below PHP condition makes it checked, as it falls under the defined condition

$class= "checked='checked'" ;
<input type="checkbox" class="chec_emp" <?php echo $class ;?> name="chec_emp[]" value="<?php echo $res_row['USERID']?>" />

The disabled checkbox is still checked. How to uncheck the disabled checkbox ?

Bram
  • 2,515
  • 6
  • 36
  • 58
Slimshadddyyy
  • 4,085
  • 5
  • 59
  • 121

1 Answers1

0

The checkbox has the attribute checked. So you need to work with this (my guess is you want to uncheck the checkbox if it´s disabled?). See e.g. the post here: check / uncheck checkbox using jquery?

EDIT: Something like

$('.chec_emp').each(function(){
if ($(this).is(':enabled')) {
    $('.chec_emp[value="'+$(this).val()+'"]').not(this).prop('disabled', 'disabled').prop('checked', false);
}
});
Community
  • 1
  • 1
Ben
  • 925
  • 5
  • 11