title: making a ball to bounce when a button is clicked
body: <p>I wrote a program to move a ball when a button is clicked. It is a part of experiment for a bigegr project:<br>
  Here is the screen shot:<br>
  <img src="https://i.stack.imgur.com/OiSe1.png" alt="website"><br>
  And here is the code:  </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;HTML5 Random Bouncing Ball&lt;/title&gt;
  &lt;style type="text/css"&gt;
  &lt;!--
  body { background-color:#ededed; font:normal 12px/18px Arial, Helvetica, sans-serif; }
  h1 { display:block; width:600px; margin:20px auto; padding-bottom:20px; font:normal 24px/30px Georgia, "Times New Roman", Times, serif; color:#333; text-shadow: 1px 2px 3px #ccc; border-bottom:1px solid #cbcbcb; }
  
  #myCanvas { background:#fff; border:1px solid #cbcbcb; }
  #nav { display:block; width:100%; text-align:center; }
  #nav li { display:block; font-weight:bold; line-height:21px; text-shadow:1px 1px 1px #fff; width:100px; height:21px; padding:5px; margin:0 10px; background:#e0e0e0; border:1px solid #ccc; -moz-border-radius:4px;-webkit-border-radius:4px; border-radius:4px; float:left; }
  #nav li a { color:#000; display:block; text-decoration:none; width:100%; height:100%; }
  --&gt;
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;
  function myFunction () {
      if(document.getElementById('button').clicked == true)
      {
          var context;
          var dx= 4;  
          var dy=4;
          var y=150;
          var x=10;
          function draw(){
              context= myCanvas.getContext('2d');
              context.clearRect(0,0,400,400);
              context.beginPath();
              context.fillStyle="#000000";
              context.arc(x,y,10,0,Math.PI*2,true);
              context.closePath();
              context.fill();
              if( x&lt;0 || x&gt;400)
              dx=-dx;
              if( y&lt;0 || y&gt;300)
              dy=-dy;
              x+=dx;
              y+=dy;
          }
          setInterval(draw,10); 
      }
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="container"&gt;
  
      &lt;canvas id="myCanvas" width="400" height="300"&gt;&lt;/canvas&gt;
  
  
  
  &lt;/div&gt;
  &lt;input id="button" type="submit" name="button" value="enter" onclick="myFunction();"/&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;  
  </code></pre>
  
  <p>The problem is: When I click that button, the ball won't be animated or moved. Where am I wrong? </p>