I used a for loop to copy the content of the table n times. Unfortunately, the code I mentioned below works only for the 1st table only.
How can I make it work for every tables? Please suggest some solutions for this. (I am a beginner)
function copy() {
var text1 = document.getElementById("Name1").value;
document.getElementById("Name2").value = text1;
var text2 = document.getElementById("Name3").value;
document.getElementById("Name4").value = text2;
}
<tr><td rowspan="3" style="height:100px;">
Name <input type="text" name="Emp name" placeholder="enter your name" id="Name1"/><br>
ID <input type="id" name="Emp Id" placeholder="enter id" id="Name3" > </td>
<td style="height:150px;">
<input type="button" value="Get data" onclick="copy();"/>
<label for="text"> Name : <input type="text" id="Name2"></label>
<label for="text"> ID : <input type="id" id="Name4"></label>
</td></tr>