Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (48 sloc) 1.561 kB

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

Jump to Line
Something went wrong with that request. Please try again.