title: how to randomly create a picture in a box
body: <p>I am trying to randomly generate a picture from a selection I have within a box. So far I have this code set to go on a mouse click:</p>
  
  <pre><code>    function randomize(){
          var imgDestination = document.getElementById("stage");
          var imgAdded = imageRandomizer();
          imgDestination.appendChild(imgAdded);
          ImgRandomPosition(imgAdded);
      }
  
      function ImgRandomPosition(imgAdded){
          var left = Math.floor((Math.random() * 700) + 1)+"px";
          var top = Math.floor((Math.random() * 500) + 1)+"px";
          var imagestyle = imgAdded.style;
          imagestyle.position = "absolute";
          imagestyle.top = top;
          imagestyle.left = left;
      }
  
      function imageRandomizer(imgArray, path) {
          path = 'img/';
          var num = Math.floor(Math.random() * imgArray.length);
          var img = imgArray[num];
          var imgStr = '&lt;img src="' + path + img + '" alt = ""&gt;';
          document.write(imgStr);
          document.close();
      }
  </code></pre>
  
  <p>I don't know how to get the appendchild working. do you know how I can maybe fix that,
  Any help would be appreciated.
  Thank you.</p>