i have javascript array contains string
in format <td>200</td><td>i3</td><td>name name</td><td>extra</td>
example array[0] contains <td>200</td><td>i3</td><td>name name</td><td>extra</td>
string (and on)
how print html table while iterating through array?
you use this:
var html = '<table><tr>' + myarray.join('</tr><tr>') + '</tr></table>';
for example:
myarray = [ '<td>200</td><td>i3</td><td>name name</td><td>extra</td>', '<td>150</td><td>i1</td><td>some data</td><td>-999</td>', '<td>360</td><td>k9</td><td>other data</td><td>nothing</td>', ]; var html = '<table border=1><tr>' + myarray.join('</tr><tr>') + '</tr></table>'; document.queryselector('#mytablemustcomehere').innerhtml = html;
<div id="mytablemustcomehere"></div>
Comments
Post a Comment