title: javascript: changing the name attribute dynamically
body: <p>I have this script I'm working on and there's no errors on it but I want to add some functions on it like when I click the button it adds but I want the name attribute of the input text to be changed too.</p>
  
  <p>Here's my script:</p>
  
  <blockquote>
    <p>javascript:</p>
  </blockquote>
  
  <pre><code>var a = 1;
  function add() {
  
      var fContent = document.getElementById('1');
      var sContent = document.getElementById('2');
      if (a &lt;= 10) {
          a++;
          var objTo = document.getElementById('m');
          var divtest = document.createElement("div");
          divtest.innerHTML = (sContent.innerHTML + a + fContent.innerHTML);
          alert(divtest.innerHTML); 
          objTo.appendChild(divtest);
      }
  }
  </code></pre>
  
  <blockquote>
    <p>html:</p>
  </blockquote>
  
  <pre><code>&lt;input type="button" onclick="add();" value="+" /&gt;
  &lt;div id="m"&gt;
  &lt;div id="1"&gt;
  &lt;input type="text" name="f"&gt;
  &lt;input type="text" name="l"&gt;
  &lt;input type="text" name="m"&gt;
  &lt;/div&gt;
  &lt;div id="2"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>OUTPUT:</p>
  </blockquote>
  
  <pre><code>2
  &lt;input type="text" name="f"&gt;
  &lt;input type="text" name="l"&gt;
  &lt;input type="text" name="m"&gt;
  </code></pre>
  
  <blockquote>
    <p>EXPECTED OUTPUT:</p>
  </blockquote>
  
  <pre><code>2
  &lt;input type="text" name="f2"&gt;
  &lt;input type="text" name="l2"&gt;
  &lt;input type="text" name="m2"&gt;
  </code></pre>
  
  <p>and so on...</p>