title: how to set ID to dynamically created text box in JavaScript
body: <p>''m trying to set the <code>ID</code> for dynamically created text box using JavaScript and code like fallows...</p>
  
  <p>here QTY is Dropdown list </p>
  
  <p>like..
  <strong>HTML Code</strong></p>
  
  <pre><code> &lt;select id="Qty" name="childQty" onChange="changeIt()"&gt;
          &lt;option value="0"&gt;ZERO&lt;/option&gt;
          &lt;option value="1"&gt;ONE&lt;/option&gt;
          &lt;option value="2"&gt;TWO&lt;/option&gt;
          &lt;option value="3"&gt;THREE&lt;/option&gt;
          &lt;option value="4"&gt;FOUR&lt;/option&gt;
          &lt;option value="5"&gt;FIVE&lt;/option&gt;
      &lt;/select&gt;
  
  &lt;div id="my_div"&gt;&lt;input type="hidden" /&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>JavaScript Code</strong></p>
  
  <pre><code>function changeIt()
          {
          var sel = document.getElementById('Qty');
          var i = sel.options[sel.selectedIndex].value;
  
          my_div.innerHTML ="";
          var txtid="";
          for(var j=0;j&lt;i;j++){
          txtid='mytext'+j;
          //alert(txtid);
                  my_div.innerHTML = my_div.innerHTML +"&lt;br&gt;&lt;input type='text' name=txtid id='txtid'&gt;"
  
              }
  
          }
  </code></pre>
  
  <p>Here am trying to set <code>txtid</code> to the <code>id</code> of that text boxes which are going to create inside <code>my_div.innerHTML</code> but this is not working <code>txtid='mytext'+j;</code> and then i want to concat those all text which user will enter in the dynamically created text boxes.  </p>