title: How to loop the input type text?
body: <p>How can I loop the input type text so that it can have it's own unique attribute eg. name, value. What I mean is that for example name="text1", name="text2",. Something like that. Here is my code. Thanks :)</p>
  
  <pre><code>&lt;HTML&gt;
      &lt;HEAD&gt;
      &lt;TITLE&gt;&lt;/TITLE&gt;
      &lt;SCRIPT language="javascript"&gt;
      function add(type) {
  
          //Create an input type dynamically.
          var element = document.createElement("input");
  
          //Assign different attributes to the element.
          element.setAttribute("type", "text");
          element.setAttribute("value", "typhere");
          element.setAttribute("name", "txtbox");
  
          var btns = document.createElement("input");
  
  
          btns.setAttribute("type", "button" );
          btns.setAttribute("value", "delete");
          btns.setAttribute("name", "dlete");
  
  
          var foo = document.getElementById("fooBar");
  
          //Append the element in page (in span).
  
                  foo.appendChild(element);
                  foo.appendChild(btns);
                  var br = document.createElement("br");
                  foo.appendChild(br);
  
      }
      &lt;/SCRIPT&gt;
      &lt;/HEAD&gt;
      &lt;BODY&gt;
      &lt;FORM&gt;
      &lt;H2&gt;&lt;/H2&gt;
  
      &lt;BR/&gt;
  
  
      &lt;INPUT type="button" value="Add" onclick="add(document.forms[0].value);"/&gt;
  
      &lt;span id="fooBar"&gt;&lt;br/&gt;&lt;/span&gt;
  
      &lt;/FORM&gt;
      &lt;/BODY&gt;
      &lt;/HTML&gt;
  </code></pre>