Assign function to window.onload - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window Load

Description

Assign function to window.onload

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script>
function LoadArray(){/*from   w  ww  . j  a v  a  2s  . c o  m*/
    var randomnumber=new Array();
    for(var i=0; i<=10; i++)
    {
       randomnumber[i]=Math.random();
    }
    document.getElementById("h_field").value = randomnumber[0];
}
 window.onload = LoadArray;

      </script> 
   </head> 
   <body> 
      <form id="myform" action="b.php" method="GET"> 
         <input type="hidden" id="h_field" name="h_field"> 
         <input type="Submit" value="my button"> 
      </form>  
   </body>
</html>

Related Tutorials