title: 'value.length' is null or not an object
body: <p>What's causing this error? Should I pass element.value into the function? I know how to set this up in a JSP, but not in JavaScript. I'm having trouble passing values into another function.</p>
  
  <pre><code>function editCommentToggle( id )
  {
      theRow = document.getElementById("id"+id);
      //user = theRow.cells[0].innerHTML;
      //date = theRow.cells[1].innerHTML;
      com = theRow.cells[2].innerHTML;
  
  
      idx = 2;
      maxlength = 250;
      // Comment field
  
      cell = theRow.cells[idx];
      while( cell.childNodes.length &gt; 0 )
          cell.removeChild(cell.childNodes[0]);
      element = document.createElement("textarea");
      element.id="comments-"+id;
      element.rows="3";
      element.value = com;
      element.style.width = "400px";
      element.maxLength = "250";
      element.onfocus = element.onkeydown = element.onkeyup = function(){
              return characterCounterEdit(undefined, maxlength, element);
      }; 
      cell.appendChild(element);
  
  
  
  function characterCounterEdit(id, maxLen, inputElement)
  {
      spanId = document.getElementById(id);
  
      if (spanId)
      {
          // Update the counter the user sees.
          var whatIsLeft = maxLen - inputElement.value.length;
  
          if ( whatIsLeft &lt; 0 ) whatIsLeft = 0;
          spanId.innerText = whatIsLeft;
      }
  
      // Restrict user from entering more than the maxlen.
   **ERROR HERE--&gt;&gt;&gt;**   if ( inputElement.value.length &gt; maxLen )
      {
          inputElement.value = inputElement.value.substring( 0, maxLen );
      }
  }
  </code></pre>