Multiple OnLoad() Statements
Posted in Programming on January 12th, 2008 by Jason – Be the first to commentIt is sometimes necessary to use multiple onload statements within the body tag of you website. You might use them to preload images for hover over effects, or to set values of a form if there are values being passed from a different page, ie. $_GET values in php.
Okay, first to explain why in the world you would need to use an onload javascript for values passed to the page through the url. Yes you could just as easily use php to auto populate the form. In fact this is usually the case, and what I do for most pages.
To use these statements is fairly easy
body onload="function(values);function2(values)"
When using multiple javascript functions with body onload you need to separate them with a semicolon (;). You can also use the following code if you need to execute many functions on page load, but want to keep your code looking nice.
body onload="allfunctions()"
function allfunctions(){
function1();
function2();
function3();...
}