Reputation: 373
I want to make proses where my data is exist the checkbox will become false
, so here is the image that i tried, and using with console.
I tried to get the column and row to make checkbox become false like here.
let tblModul = document.getElementById('myTable');
console.log('col :' + col);
console.log('row :' + row);
const [intersections, difference, falsecheked] = datarelationships(theemployee, theEmpDatInTable, 'nik', 'NIK');
appendTheTableEmployee(difference.length, tbody, difference)
console.log(falsecheked);
if(falsecheked == false){
tblModul.rows[row].cells[col].checked = false;
}
Is there a problem with my code? because eventough i got the value false, the checkbox didn't unchecked
Upvotes: 1
Views: 443
Reputation: 12629
You are using tblModul.rows[row].cells[col].checked = false;
which will try to set checked = false
on cell
but you need to perform it on input
inside that cell
. So you can use like tblModul.rows[row].cells[col].querySelector('input').checked = false;
.
Try it below.
let tblModul = document.getElementById('myTable');
// in your code use row & col variables I have statically used for testing.
tblModul.rows[0].cells[0].querySelector('input').checked = false;
tblModul.rows[1].cells[0].querySelector('input').checked = true;
<table id='myTable'>
<tr>
<td><input type='checkbox' checked></td>
</tr>
<tr>
<td><input type='checkbox' checked></td>
</tr>
</table>
Upvotes: 2