title: HTML Form onclick event doesn't call javascript function
body: <p>I would like to create a dynamic form, adding inputs into the form by pressing a button (or an image)
  when I put the code directly on the onclick event </p>
  
  <pre><code>alert("Hello");
  </code></pre>
  
  <p>it works... however, it doesn't when I try to call a javascript function... Even If I call the  simple function hello(); (as well with add() )</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
  &lt;script type="text/javascript"&gt;
  function add() {
      var container = document.createElement("div"); 
      container.innerHTML = "&lt;input type='text' name='email'&gt;&lt;br/&gt;";
      document.getElementById('emails').appendChild(container);
  }
  function hello() {
      alert("Hello"); 
  }
  ​&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="myform" name="myform" action="valid.php" method="POST"&gt;
      &lt;div id="emails"&gt;
          &lt;input type='text' name='email' value=''/&gt;&lt;br /&gt;
      &lt;/div&gt;
      &lt;img width="50px" src="myimage.jpg" onclick='add();'/&gt;
      &lt;input type="submit" value="Submit"/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Anyone manage to spot why ?</p>