A generic function to create form elements - Node.js HTML

Node.js examples for HTML:Element

Description

A generic function to create form elements

Demo Code

function createFormElement(element, type, name, id, value, parent) {
    var e = document.createElement(element);
    e.setAttribute("name", name);
    e.setAttribute("type", type);
    e.setAttribute("id", id);
    e.setAttribute("value", value);
    parent.appendChild(e);/*from ww  w  .ja  v a 2 s  .  c  om*/
}

Related Tutorials