Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your HTML table is this...</p> <pre><code>&lt;table id=data_table&gt; &lt;thead&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>You could insert like this...</p> <pre><code>var user = { "10000068485": {"id":"10000068485","name":"Jenan"}, "10000099257": {"id":"10000099257","name":"John"} }; var tbody = document.getElementById('data_table').tBodies[0]; for (var key in user) { if (user.hasOwnProperty(key)) { var row = tbody.insertRow( tbody.rows.length ); row.insertCell( 0 ) .appendChild( document.createTextNode( user[key].id ) ); row.insertCell( 1 ) .appendChild( document.createTextNode( user[key].name ) ); } } </code></pre> <p><strong>DEMO:</strong> <a href="http://jsfiddle.net/qtcTS/1/" rel="nofollow">http://jsfiddle.net/qtcTS/1/</a></p> <hr> <p>Here's an example that creates new elements in a div.</p> <p>The resulting structure will look like:</p> <pre><code>&lt;div id=main&gt; &lt;p&gt; &lt;span&gt;10000068485&lt;/span&gt; &lt;span&gt;Jenan&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;span&gt;10000099257&lt;/span&gt; &lt;span&gt;John&lt;/span&gt; &lt;/p&gt; &lt;/div&gt; </code></pre> <p>JS</p> <pre><code>var user = { "10000068485": {"id":"10000068485","name":"Jenan"}, "10000099257": {"id":"10000099257","name":"John"} }; var p, main = document.getElementById('main'); for (var key in user) { if (user.hasOwnProperty(key)) { p = main.appendChild( document.createElement('p') ); p.appendChild( document.createElement('span') ) .appendChild( document.createTextNode( user[key].id ) ); p.appendChild( document.createElement('span') ) .appendChild( document.createTextNode( user[key].name ) ); } } </code></pre> <p><strong>DEMO:</strong> <a href="http://jsfiddle.net/qtcTS/2/" rel="nofollow">http://jsfiddle.net/qtcTS/2/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload