get-set-form-values

4.0.0 • Public • Published

get-set-form-values

Simple object for getting and setting form values using javascript

Inspiration from this stackoverflow answer (for the setting part):

https://stackoverflow.com/a/35468919/464549

Install

npm install --save get-set-form-values

Or

<script src="dist/get-set-form-values.js"></script>

Usage

 
// Will only work in a browser
 
var formValues = require('get-set-form-values');
 
// Get a form element
var mainForm = document.getElementById('main_form');
 
// Get the values
var values = formValues.get(mainForm);
 
// Set some values
var loadJsonValues = {"radio": "d", "fulltext": "Area", "range": "9", "checkbox": ["B"], "input": "Text", "select": ["saab", "mercedes"], "select-single": "volvo"};
formValues.set(mainForm, loadJsonValues);

Full example. See: index.html

Live example:

See: https://codepen.io/diversen/full/yoVQZq/

MIT © Dennis Iversen

Package Sidebar

Install

npm i get-set-form-values

Weekly Downloads

1

Version

4.0.0

License

MIT

Unpacked Size

14.9 kB

Total Files

7

Last publish

Collaborators

  • diversen