JSFiddle - React, Tailwind, and code Playground
by qustosh
JavaScript
//FORM CREATOR
var f = {
"name" : "text",
"surname": "text",
"age": "text"
}
function Form(fields){
var html;
this.fields = fields || {};
this.create = function(){
var all = "";
for(var f in this.fields){
all += "<label>"+ f +"</label>";
all += "<input type='"+ fields[f]+"' name='"+ f +"'><br>"
}
all = "<form>" + all + "</form>";
html = all;
};
this.render = function(){
return html;
};
this.init = function(){
this.create();
}
this.init();
}
var form = new Form(f);
console.dir(form);
document.write(form.render())
$("input").css({"margin-left":"50px"})
$("form").css({"border":"solid 1px black"})