I want when anybody clicks "Add Value" table rows should be created with the textarea values(Please refer Image for more understanding!). I am facing problem will doing for loop, I want all for loop condition should perform at same time. Please tell me how I can perform all for loops condition at same time.
[Image][1]
[JsFiddle][2]
Code:
<div dir="ltr" style="text-align: left;" trbidi="on">
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
</style>
</head>
<body>
<center>
<textarea cols="50" id="input1" rows="10">
1
2
3
4
5
</textarea>
<br />
<textarea cols="50" id="input2" rows="10">
1
2
3
4
5
</textarea>
<br />
<textarea cols="50" id="input3" rows="10">
1
2
3
4
5
</textarea>
<br />
<textarea cols="50" id="input4" rows="10">
1
2
3
4
5
</textarea>
<br />
<textarea cols="50" id="input2" rows="10">
1
2
3
4
5
</textarea>
<br />
<button onclick="myFunction()">Add Values</button><br /><br />
<table id="myTable">
<tr>
<th>Sr No</th>
<th>Contact</th>
<th>Country</th>
<th>Sr No</th>
<th>Sr No</th>
</tr>
</table>
<br>
<button id="btnCopy">
Copy Table!</button><br>
</center>
</body>
<script>
function myFunction() {
const values1 = document.querySelector('#input1')
.value.trim().split('\n');
const values2 = document.querySelector('#input2')
.value.trim().split('\n');
const values3 = document.querySelector('#input3')
.value.trim().split('\n');
const values4 = document.querySelector('#input4')
.value.trim().split('\n');
const values5 = document.querySelector('#input5')
.value.trim().split('\n');
const table = document.querySelector('#myTable');
for (const value1 of values1 && const value2 of values2 && const value3 of values3 && const value4 of values4 && const value5 of values5)
table.innerHTML += `
<tr><th>${value1}</th><td><b>${value2}</b></td><td>${value3}</td><td>${value4}</td><td>${value5}</td></tr>
`;
}
</script>
</html>
</div>
[<>]toolbar button); here's how to do one.