title: dynamically added text id, getElementById
body: <p>I create text box dynamically and assign its ID dynamically. in javascript if I call getElementById the alert fails, just nothing happens.</p>
  
  <pre><code>&lt;% for(int i=0; i&lt;lines.length;i++) {
    if(lines[i].contains(" ")) { %&gt;
      &lt;input type=text name='key1&lt;%=i%&gt;' id="idkey&lt;%=i%&gt;" value ="&lt;%=abc%&gt;"/&gt;
                            &lt;%
    }
  } %&gt;
  </code></pre>
  
  <p><strong>Javascript :</strong></p>
  
  <pre><code>for(j=0; j&lt;len; j++){
    var lblElement = getElementById("idkey"+j);
    alert(lblElement);
  }
  </code></pre>