Friday, 4 March 2011

Random Minute Generator

Had a need to turk some numbers for putting into a DATETIME field in MySQL so came up with this little script for generating a set of minutes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Random Minute Generator</title>
    <script type="text/javascript">
      window.onload = function addNumbers(){
        for(var x = 0; x < 217; x++){
          if (document.createTextNode){
            var myNumber = Math.floor(Math.random()*60) + 1;
            if(myNumber < 10){
              myNumber = "0"+myNumber;
            }
            var myText=document.createTextNode(myNumber);
          }
          document.getElementById("myDiv").appendChild(myText);
          var newLine=document.createElement('br');
          document.getElementById("myDiv").appendChild(newLine);
        }
      }
    </script>
  </head>
  <body>
    <div id="myDiv">
    </div>
  </body>
</html>

Do enjoy if you use it and perhaps leave a comment...?

No comments:

Post a Comment