title: create input text with loop js
body: <p>I would like to know how could I create many <code>&lt;input type=text /&gt;</code> tags with a loop in JS.</p>
  
  <p>I need that loop to be linked to a first input (<code>type=number</code>), which tell to the loops how many input text to create. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function getP () {
    var nbP = Number(document.getElementById("nombreP").value);
  
    for (var i = 0; i &lt; nbP; i++) {
        var newForm = document.createElement("input[type=text]");
            newForm.id = "form"+i
        document.body.appendChild(newForm);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form method="get"&gt;
      &lt;input type="number" name="nombrePlat" id="nombreP"&gt;
      &lt;input type="submit" value="Envoyer" id="ok" onclick="getP()"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>