Hi guys, how can I go about creating a form with javascript?
I have NO idea on how to proceed, I have been googling my face off but there is nothing definitive that can show me how to dynamically create forms with it.
Thanx in advance!
Hi guys, how can I go about creating a form with javascript?
I have NO idea on how to proceed, I have been googling my face off but there is nothing definitive that can show me how to dynamically create forms with it.
Thanx in advance!
Just use the standard DOM API (document.createElement()
, see these docs for an example) to create all the elements of the form.
My recommendation would be to get the underscore.js library and use its template
function to create your forms. (If underscore is too large for you, the template function can stand on its own too).
Yes, you can create any amount of html including forms by running javascript,
Perhaps:`
<html>
<body>
<h1>My Form</h1>
<div id="formcontent">
</div>
</body>
</html>
Our javascript might look like:
var e1 = document.CreateElement("input");
el.type = "text";
el.name = "myformvar";
var cont = document.GetElementById("formcontent")
cont.appendChild(e1);