title: Better way to dynamically create HTML form
body: <p>I need to dynamically create HTML form. So I can to it using 2 approaches:</p>
  
  <p>1) Use JS to create form</p>
  
  <pre><code>  var myId = document.createElement("input");
    myId.setAttribute("type", "hidden");
    myId.setAttribute("name", "myId" + index);
    myForm.appendChild(myId);
  </code></pre>
  
  <p>and so on.. </p>
  
  <p>2) Use <code>innerHTML</code> and writing valid HTML code:</p>
  
  <pre><code>    document.getElementById("myForm").innerHTML += 
  '&lt;input type="hidden" name="myId' + index + '"/&gt;';
  </code></pre>
  
  <p>What approach is better? What is usually way to dynamically create form? For me second approach is more readable</p>