I need to dynamically create HTML form. So I can to it using 2 approaches:
1) Use JS to create form
var myId = document.createElement("input");
myId.setAttribute("name", "myId" + index);
and so on..
innerHTML and writing valid HTML code:
'<input type="hidden" name="myId' + index + '"/>';
What approach is better? What is usually way to dynamically create form? For me second approach is more readable
second approach is the best because it gives you the possibility to verify the exact composition of the page. at least in my opinion.