Generate array with random number - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Generate array with random number

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script>
function LoadArray(){/* w w  w . j  a  v a  2 s. 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