All Projects → serbanghita → formToObject.js

serbanghita / formToObject.js

Licence: other
Convert a HTML form to a JS literal (multidimensional) object.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
typescript
32286 projects

Projects that are alternatives of or similar to formToObject.js

sexy form.rb
Dead simple HTML form field builder for Ruby with built-in support for many popular UI libraries such as Bootstrap
Stars: ✭ 38 (-56.32%)
Mutual labels:  html-form
Formidable
The PHP pragmatic forms library
Stars: ✭ 116 (+33.33%)
Mutual labels:  html-form
Learn To Send Email Via Google Script Html No Server
📧 An Example of using an HTML form (e.g: "Contact Us" on a website) to send Email without a Backend Server (using a Google Script) perfect for static websites that need to collect data.
Stars: ✭ 2,718 (+3024.14%)
Mutual labels:  html-form
Form
jQuery Form Plugin
Stars: ✭ 5,122 (+5787.36%)
Mutual labels:  html-form
jquery-load-json
jQuery plugin that enables developers to load JSON data from the server and load JSON object into the DOM
Stars: ✭ 26 (-70.11%)
Mutual labels:  html-form
form builder.cr
Dead simple HTML form builder for Crystal with built-in support for many popular UI libraries such as Bootstrap
Stars: ✭ 29 (-66.67%)
Mutual labels:  html-form

formToObject.js

Build Status NPM package NPM downloads

Convert HTML forms with all their fields and values to multi-dimensional JavaScript objects

Install

Node.js

  • npm install form_to_object

Browser

<!-- Include minified script (~2kb) -->
<script src="dist/formToObject.min.js"></script>

Usage

Using the DOM node id.

formToObject('myFormId');

Using the actual DOM Node reference.

formToObject(document.getElementById('myFormId'));

Result

{
  saveSettings: 'Save',
  name: 'Serban',
  race: 'orc',
  settings: {
     input: 'keyboard',
     video: {
        resolution: '1024x768',
        vsync: 'on'
     }
  }
}

XHR - sending form data

$.ajax({
  'url': '/app/settings/save/',
  'type': 'post',
  'data': formToObject('saveSettingsForm'),
  'success': function(r){}
});
Browser support

IE 8, Firefox 3.5, Chrome, Safari, Opera 10, every mobile browser.

Screenshot

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].