js increment safety value html

Solutions on MaxInterview for js increment safety value html by the best coders in the world

showing results for - "js increment safety value html"
Erik
20 May 2020
1function addRow(tableID) {
2
3        var table = document.getElementById(tableID);
4
5        var rowCount = document.getElementById(tableID).getElementsByTagName('tbody')
6        [1].getElementsByTagName('tr').length;
7        var row = table.insertRow(rowCount +1);
8
9        var cell1 = row.insertCell(0);
10        var element1 = document.createElement("input");
11        element1.type = "hidden";
12        element1.name = "Q[]";
13        element1.value = rowCount +1;
14        cell2.appendChild(element1);
15        cell2.innerHTML = rowCount +1;
16}
17
18function deleteRow(tableID) {
19        try {
20        var table = document.getElementById(tableID);
21        var rowCount = table.rows.length;
22
23        for(var i=0; i<rowCount; i++) {
24            var row = table.rows[i];
25            var chkbox = row.cells[0].childNodes[0];
26            if(null != chkbox && true == chkbox.checked) {
27                table.deleteRow(i);
28                rowCount--;
29                i--;
30            }
31
32
33        }
34        }catch(e) {
35            alert(e);
36        }
37}
38