form-data-set

Extract form data from a hash of elements

npm install form-data-set
5 downloads in the last day
7 downloads in the last week
65 downloads in the last month

form-data-set

dependency status

browser support

Extract form data from a hash of elements

Example

var document = require("global/document")
var console = require("console")

var FormData = require("form-data-set")

var elements = createElements()

document.body.appendChild(elements.root)

elements.root.addEventListener("change", function (ev) {
    console.log("formdata", FormData(elements))
})

// DOM Verbosity
function createElements() {
    var template = "\
        <div>\
            <div><label> Text field \
                <input class='input' />\
            </label></div>\
            <div><label> Text area \
                <textarea class='textarea'></textarea>\
            </label></div>\
            <div><label> Check box \
                <input type='checkbox' class='checkbox'></input>\
            </label></div>\
        </div>"

    var container = document.createElement("div")
    container.innerHTML = template.trim()
    var root = container.firstChild

    return {
        root: root
        , input: root.getElementsByClassName("input")[0]
        , textarea: root.getElementsByClassName("textarea")[0]
        , checkbox: root.getElementsByClassName("checkbox")[0]
    }
}

Installation

npm install form-data-set

Contributors

  • Raynos

MIT Licenced

npm loves you