set-form-data
Sets form data - or data for a named form element - via form.elements
.
This project is meant to be the counterpart to get-form-data
by insin
, and heavily borrows from its
codebase; the project should be considered almost a fork.
Currently works in an ES6/webpack setting. Will make browser bundles later if there's interest in the project. Please open an issue!
Install
npm install set-form-data
Usage
Setting form data
To set data for an entire form, use the setFormData()
function:
... Product: T-shirt Hat Shoes Quantity: Express shipping Do you want to use Express Shipping? Yes No Terms of Service: I have read and agree to the Terms of Service. Yes ...
var form = document var data = ;console
{"product": "1", "quantity": "9", "shipping": "express", "tos": "Y"}