title: Get value of dynamically created textbox using JavaScript
body: <p>I'm using JavaScript to dynamically add rows to a table, I create some textboxes in each row, I've added an onkeyup event to one of my textboxes:</p>
  
  <pre><code>               var myTotal = "1";
             var spanTotal = document.createElement("span");
             spanTotal.innerHTML = "&lt;input style=\"width:50px\" type=\"text\" name=\"total\" value=" + myTotal + "&gt;";
  
  
  spanCount.onkeyup = function ()
  {
  alert(spanTotal.innerHTML);
      };
  </code></pre>
  
  <p>then I add this span (which is rendered as an HTML textbox) to my table row. I want to have value of my dynamically created textbox, but whenever I change this textbox, initial value of this textbox is displayed in alert box (i.e. 1). Initial value of this textbox is "1", but when I change it (for instance type a 0 in textbox), again "1" is displyaed in alert box. I want to have value of my dynamically created textbox, should I give an ID to my span? how should I define spanCount.onkeyup function? where should it be defined so that I can have exact value of this textbox?</p>