Basically I have a table that I generating using javascript. I wrote a function to build the row and I call it a bunch of times with different parameters.

I know the individual functions work because I can pull them onto their own page and attach them to an onclick event with a button.

What I need to know is how to get the page to run the script/function when the page loads so the table is there when the user gets to the page.

I have tried using the onload event in the body tag but no luck so far.

Thanks in advance,
David

Recommended Answers

All 5 Replies

it will not work on onload event as dom tree has not been yet formed.

try this:
---------
suppose function name is myFun(); then call it inside script block just after body tag , like this

<body>
 <script>
    myFun();
 </script>
</body>

Nope. Still nothing.

Member Avatar for electron33

Have you tried onLoad="javascript:myFun()" in the body tag?

You can also call the function with window.onLoad = myFun; inside the script block

can u post u'r code.

Don't ask me why, but I finally got it working.

I just deleted everything out of the page and started from scratch. Which somehow made the onload event work. Thanks for the help everyone!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.