title: Javascript pass a variable from function call to innerHtml
body: <p>Ok, this might be an easy one, im just not sure how to do it.  I have a main function where it's taking in an "id".  This id is unique and I want to pass it over to another function that is doing a count for me and returns that count to an innerHtml span tag.</p>
  
  <p>Reason for this is because I can have 5 of these open at the same time, but they will have the same span id name "editCommentsCounter"...I want them to be like "editCommentsCounter-id"</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].innerText ;
      comLength = theRow.cells[2].innerText.length ;
  
      idx = 2;
      maxlength = 250;
      count = maxlength - comLength;
  
  
          // Comment field
          cell = theRow.cells[idx];
          while( cell.childNodes.length &gt; 0 ) cell.removeChild(cell.childNodes[0]);
  
          spanTag = document.createElement("span"); 
          spanTag.innerHTML = "You have &lt;strong&gt;&lt;span id='editCommentsCounter'&gt;"+count+"&lt;/span&gt;&lt;/strong&gt; characters left.&lt;br/&gt;"; 
          cell.appendChild(spanTag);
          element = document.createElement("textarea");
          element.id="commentsTextArea-"+id;
          element.rows="3";
          element.value = com;
          element.style.width = "400px";
          element.maxLength = "250";
          element.onfocus = element.onkeydown = element.onkeyup = function(){return characterCounterEdit('editCommentsCounter', maxlength, this);}; 
          cell.appendChild(element);
  </code></pre>
  
  <p>}</p>
  
  <p>Basically I want to take :</p>
  
  <pre><code>   spanTag.innerHTML = "You have &lt;strong&gt;&lt;span id='editCommentsCounter'&gt;"+count+"&lt;/span&gt;&lt;/strong&gt; characters left.&lt;br/&gt;"; 
  </code></pre>
  
  <p>and make that into something like `span id='editCommentsCounter-' + id</p>
  
  <p>so when I call this:</p>
  
  <p><code>element.onfocus = element.onkeydown = element.onkeyup = function(){return characterCounterEdit('editCommentsCounter', maxlength, this);};</code> </p>
  
  <p>I call this above with editCommentsCounter with that id attached to it</p>
  
  <p>See what Im saying?</p>