I have four arrays
arrayOne['orange','blue','green','red','yellow','purple','gray','tan','pink','violet']
arrayTwo['1001','1003','3453','78934','2389','3','8934']
arrayThree['TV','phone','laptop']
arrayFour['1','2','3','4','5','6','7','8','9','10']
I am making a table in html
<table class="table table-striped">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
</tr>
</thead>
I have a script that opens a modal and appends to the table I have tried to get it working for two columns but it is only populating the first column with ArrayOne contents
for (row = 0; row <$(this).data("arrayOne").length; row++ ){
$("#myModal").find(".table").append("<tr>
<td>"+$(this).data("arrayOne")[row]+"</td>");
for (j = 0; j <$(this).data("arrayTwo").length; j++ ){
$("#myModal").find(".table").append("<tr>
<td>"+$(this).data("arrayTwo")[j]+"</td></tr></tbody></table>");
}
}
With the code above it only prints out as
column1 column2 column 3 column 4
orange
blue
green
red
....
violet
The end result should look something like this
column1 column2 column 3 column 4
orange 1001 TV 1
blue 1003 phone 2
green 3453 laptop 3
red 78934 4
yellow 2389 5
Etc, Etc
<tr>before opening a new one.. EDIT: one of your problems is also that by appending raw html code, you should fill rows with all of your 4 arrays at once, because a<tr>is the horizontal part of that table