HTML from with table and button:
<div>
<h1>Info</h1>
<form>
<table id="t">
<tr>
<th></th>
<th>index</th>
<th>name</th>
<th>job</th>
<th>date</th>
<th>department</th>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>1</td>
<td>Alex</td>
<td>Hacker</td>
<td>100000000000000000</td>
<td>2</td>
</tr>
</table>
<br/>
<input type="submit" value="delete" onclick="deleteRow()">
</form>
</div>
I want to remove rows, which have establishes checkbox. Delete should be at the click of a button.
Javascript function that should delete:
function deleteRow() {
let table = document.getElementById('t')
let boxs = table.getElementsByTagName("input")
for (i = 0; i < boxs.length; i++){
if(boxs[i] == true) {
table.deleteRow((boxs[i].parentNode.parentNode).rowIndex)
}
}
}
I debugged this code, the size of the array defined correctly, but doesn't enter to condition.