title: Add text to value of textarea on blur without jquery
body: <p>So, I have a textarea in a form that records comments. I am attempting to append the identity of the user entering the comment to the end of the comment when entered.</p>
  
  <p>Here is the PHP that checks the user session and gets the name of the user:</p>
  
  <pre><code>&lt;?php 
      //getting username - displays John Doe
      $user = Mage::getSingleton('admin/session');
      $firstname = $user-&gt;getUser()-&gt;getFirstname();
      $lastname = $user-&gt;getUser()-&gt;getLastname();
      $append = " [name](by ".$firstname." ".$lastname.")[/name]";
  ?&gt;
  </code></pre>
  
  <p>The JavaScript that should be appending to the value on blur:</p>
  
  <pre><code>&lt;script&gt;
      function addedcomment(){
          var commentby = document.getElementById("#history_comment").value;
          var commentby = commentby + '&lt;?php echo $append; ?&gt;';
          document.getElementById('#history_comment').value = commentby;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The textarea that comments are entered into:</p>
  
  <pre><code>&lt;textarea name="history[comment]" rows="3" cols="5" style="height:6em; width:99%;" id="history_comment" onBlur="addedcomment()"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>The code appears on the page exactly in the order and manner that it has been shown here, so the PHP sets the value of $append before the JavaScript appears. I am getting three errors in the dom console:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'value' of null
  addedcomment
  onblur
  </code></pre>
  
  <p>The CMS I am using works with Prototype, so jQuery does not work all of the time (it seems it is selectively called in) even in noConflict mode.</p>
  
  <p>Things I have tried:</p>
  
  <pre><code>Putting the JS below the textarea.
  onblur vs onBlur
  jQuery solution
  </code></pre>