javascript - Disable/enable input box type 'number' on tick of checkbox in an HTML table -
i want disable/enable input tag type number when checkbox ticked. checkboxes on same row input tag placed. have tried method
$(document).on('change', '.ch_attend', function () { if(this.checked){ $(this).closest('tr').find('input:text').prop('disabled', false); $(this).closest('tr').find('button').prop('disabled', false); $(this).closest('tr').find('input:text').val(0); computekpi(); }else{ $(this).closest('tr').find('input:text').prop('disabled', true); $(this).closest('tr').find('button').prop('disabled', true); $(this).closest('tr').find('input:text').val(0); computekpi(); $('#chkall').prop('checked', false).uniform(); } }).find('.ch_attend').change();
and change input:text input:number didn't work. works when type text
the type of input on dom number not input type='text' anymore.
if($retval->num_rows>0){ while($row = $retval->fetch_assoc()){ $dom_string .= "<tr> <td style='text-align-last: center;'><label><input type='checkbox' class='ch_attend'></label></td> <td style='text-align-last: center;'><label>".$row['full_name']."</label></td> <td style='text-align-last: center;'><input disabled='true' style='text-align-last: center; width: 40px; height: 25px;' class='form-control score' data-id='".$row['id']."' type='number' min='0' step='any' value='0'></td> <td style='text-align-last: center;'><input disabled='true' style='text-align-last: center; width: 40px; height: 25px;' class='form-control totalscore' data-id='".$row['id']."' type='number' min='0' step='any' value='0'></td> <td style='text-align-last: center;'><button type='button' disabled='true' class='btn btn-warning btn-xs action' data-full_name='".$row['full_name']."' style='height: 20px; width: 35px; padding-top: 0px; padding-bottom: 0px;'><span class='icon icon-check' style='font-size:10px; line-height: 20px;'></span></button></td> </tr>"; $_session['cnt'] += 1; } }
html markup came ajax success result.
i'm confused now. please me on how that. thank you.
i think you're looking input[type=number]
, input[type=text]
Comments
Post a Comment