Javatpoint Logo
Javatpoint Logo

Framework7 Form Data

There are some form data methods which makes working with forms easy. See the two form data methods:

Form to JSON The formToJSON() method is used to convert all form fields values to JSON.

Form from JSON: The formFromJSON method is used to fill up form according to JSON data.

Form to JSON

Framework7 provides a method myApp.formToJSON(form) to convert all form field values to JSON.

myApp.formToJSON(form): This method accepts form as parameter which is a HTMLElement or string of form that must be converted to JSON. This parameter is required and this method returns JSON data.

Each input must have the name attribute, otherwise its value will not appear in JSON. Multiple selects and checkboxes will appear as arrays in JSON.

Example

Let's take an example to demonstrate the use of form to JSON in Framework7:

Test it Now

Form from JSON Example

Framework7 facilitates you to fill up the form according to JSON by using the following method:

myApp.formFromJSON(form, formData): This method accepts two parameters:

  • form: It is a HTMLElement or string of form that must be converted to JSON. This is a required parameter.
  • formData: This is the object with form data in JSON format. This is a required parameter.

Let's take an example to demonstrate the use of form from JSON in Framework7:

Test it Now




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA