title: Writing text on "div" using JavaScript
body: <p>I'm having some trouble whenever I want to add some text to my div tag, here's my code:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;body&gt;
  &lt;div id="comments"&gt;
  
  &lt;/div&gt;
  &lt;form name="forma"&gt;
  &lt;textarea name="commentUser" id="commentUser" cols="40" rows="5"&gt;
  Comments here...
  &lt;/textarea&gt;&lt;br&gt;
  &lt;input type="submit" value="Ready!" onClick="writeComment()" /&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript" &gt;
  
  function writeComment()
      {
      var comment = document.forma.commentUser.value;
      alert(comment);
  
      document.getElementById('comments').innerHTML=comment;
  
  
      }
  
  
  &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>It does what it has to do correctly, but then it switches back to the text box only and the comment I just wrote disappears. Any idea of what's going on here?</p>
  
  <p>Thank you so much for your time.</p>