0

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...

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

Any feedback is appreciated!

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

2

1 Answer 1

2
<body onload="Javascript:populateTable()">  
    <div id="productTable">
    </div>
</body>

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much. Exactly what I wanted to achieve.. onto making it better!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.