Karl Boyle Karl Boyle - 1 year ago 172
Javascript Question

Populate html table onload from javascript

I was following an example source code I found for populating a html table from javascript.
However there is a disconnect in my knowledge. The javascript is inside a populateTable function to find an element and create the other elements for the table and populate it from an array.

I don't want this to be done from a button click but when the screen loads.

So lets say...

<p>List of products below:</p>
<table> <--- how do I tell this table to be populated from my populateTable function

Any feedback is appreciated!

EDIT: - I'm clearly learning javascript :) Trying to do core javascript.

Answer Source
<body onload="Javascript:populateTable()">  
    <div id="productTable">

Stick this into your html pane, the body will run your function on load and get the desired result.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download