Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

adding a row with checkbox in it

$
0
0

how i can modify the code here, so when i add a new row in the table, it will add together with the checkbox in it. And down below i have a code copied from internet, to delete the ones which i checked, so can you give me a hint, how to modify that one too please.

Thank You. With Respect Umer Selmani

<!DOCTYPE html><html><head><style>
          table,
          td {
            border: 1px solid black;
          }</style></head><body><table id="myTable"><tr><td>R1 C1 </td><td>R1 C2 </td><td><input type="checkbox" /></td></tr><tr><td>R2 C1 </td><td>R2 C2 </td><td><input type="checkbox" /></td></tr><tr><td>Row3 cell1</td><td>Row3 cell2</td><td><input type="checkbox" /></td></tr></table><button type="button" onclick="myFunction()">Add row</button><button onclick="myDeleteFunction()">Delete row</button><script>
          function myFunction() {
            var table = document.getElementById("myTable");
            var row = table.insertRow(-1);
            var cell1 = row.insertCell(0);
            var cell2 = row.insertCell(1);
            var cell3 = row.insertCell(2);
            cell1.innerHTML = "NEW CELL1";
            cell2.innerHTML = "NEW CELL2";
            cell3;
          }
          /*$("button").click(function() {
            $("table input[type='checkbox']:checked")
              .parent()
              .parent()
              .remove();
          });*/</script></body></html>

Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>