I am looking to have a function, that when pressing a button, the function generates rows/colums.
I’ve been trying with the following code
function addTRTD(){
var tbElm = document.getElementById("tbdy");
var newRow = document.createElement("tr");
var newCol1= document.createElement("TD");
var newCol2= document.createElement("TD");
newCol1.innerHTML = "Row 1 Cell 1";
newCol2.innerHTML = "Row 1 Cell 2";;
newRow.appendChild(newCol1);
newRow.appendChild(newCol2);
tbElm.appendChild(newRow);
newCol1.innerHTML = "Row 1 Cell 1";
newCol2.innerHTML = "Row 1 Cell 1";
var newRow = document.createElement("tr");
newRow.appendChild(newCol1);
newRow.appendChild(newCol2);
var newCol1= document.createElement("TD");
var newCol2= document.createElement("TD");
newCol1.innerHTML = "Row 2 Cell 1";
newCol2.innerHTML = "Row 2 Cell 2";
tbElm.appendChild(newRow);
}
but no luck. Clicking on the button I just get the following output
Row 1 Cell 1 Row 1 Cell 2
how can I get to display information of Row2?
The solution for me was:
Thank you very much everyone for your comments and help
Regards