vendredi 17 avril 2015

jQuery uncheck checkbox if disabled


<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 ?





Aucun commentaire:

Enregistrer un commentaire