jackmoore / form-to-object Goto Github PK
View Code? Open in Web Editor NEWConvert a form to an object
License: MIT License
Convert a form to an object
License: MIT License
Using a <select multiple='multiple'>
. When more than one value is selected, form-to-object
only includes one of the selected values, not all of them.
This reproduces the error:
const formToObj = require('form-to-object')
const formEl = document.querySelector('#theForm')
const params = formToObj(formEl)
console.log(params)
<form id='theForm' action='' method='post'>
<input type='hidden' name='blah' value='something' />
<select multiple='multiple' name='theMulti'>
<option value='First Choice' selected='selected'>First Choice</option>
<option value='Second Choice' selected='selected'>Second Choice</option>
<option value='Third Choice' >Third Choice</option>
</select>
</form>
{blah: "something", theMulti: "First Choice"}
I would expect something like:
{blah: "something", theMulti: ["First Choice", "Second Choice"]}
@jackmoore can you delete your fork of the same name so i can transfer this repo to u? thanks
Great library - small, powerful and few dependencies.
However, it submits readonly form fields to the server.
It seems to handle disabled fields just fine and should require just a few additional not(:read-only)
selectors to correctly ignore these fields.
Just a thought.
The package form2obj on NPM is not working, the index.js file only contains this:
module.exports = require('./lib/form2obj');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.