Kenny Shaw Kenny Shaw - 1 year ago 93
Javascript Question

Use with javascript

So I have a few javascript arrays, ex.

array1 = [1,2,3]
array2 = [4,5,6]
and I want these arrays to represent the column data, not row data like it wants.
How would I make the table to look like:


I've been pulling my hair out all day, and I can't seem to find a this even supported?

Answer Source

Simply output the data how you need it.

var rows = '';

for (var i = 0; i < array.length; i++) { //assumes equal size arrays
  rows += '<tr><td>'+array[i]+'</td><td>'+array2[i]+'</td></tr>';
  //or however you do this
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download