I have a form for which I use JQUERY templates, as there can be multiple fields for an attribute. For eg. a user can have multiple phone numbers. So, he can add fields dynamically by pressing the option "add one more number". In this way multiple fields are added but all have the same name.
How should I serialize this kind of form data into a JSON object?
--Thanks in advance
serializing a jquery template form into json using jquery
612 Views Asked by Harshit Agarwal At
2
There are 2 best solutions below
2
Yogesh
On
You can set name attribute for multiple fields to consider it as array. Example is below
<input type="text" name="phone[]"> <input type="text" name="phone[]"> <input type="text" name="phone[]">Now for submitting you can use serializeArray() function to post the data to serverside script
I hope this will work for you
Related Questions in JQUERY
- In Datatables, start value resets to 0, when column sorting
- Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
- window.location.href redirects but is causing problems on the webpage
- Using JQuery Date Slider
- Storing selected language in localStorage
- How to stop other divs from still showing when i click a different button?
- Check multiple values with jQuery
- Bootstrap component does not want to render in Datatables function
- put white spaces when entering an amount moneytype symfony
- Trouble accessing custom header in AJAX response using jQuery in Fiware Keyrock
- I just cant make it work, HTML, JS and Firebase error
- Didn't declared variable still not getting any error in JavaScript
- Move element horizontally while scrolling vertically in pure JavaScript
- allow multi carousel in same page
- Embedded TikTok posts / thumbnail styling issue
Related Questions in JSON
- Handling both JSON and form values in POST request body with unknown values in Golang
- JSON Body is Not Passing Certain Strings
- Custom rewriter for json
- TypeScript: Type checking while parsing an arbitrary JSON that is typed/
- I dont understand what to do with: System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IEnumerable`1
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Dynamic Nested Multi-Dimensional Arrays in Rust
- Creating bar chart in FastAPI
- How to encode ttsJson data?
- Trying to get the id of the last element in my json file through an api
- How to give index id to my uploaded json file in FastAPI?
- JQ JSON - Values to Array
- Spring boot JSON parse error: Unexpected character error
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Sigma.JS custom rendering
Related Questions in SERIALIZATION
- Deserialize XML with optional different name
- How to serialize Any with Kotlin serialization?
- Flink Stuck on Broadcast
- How do I add serialization into Kotlin Jet Compose project?
- fix django login bug
- How to execute code "before_serialize"? or How can I sanitize attributes before they are serialized?
- Ical.net Serialization Error when serializing 12:00 AM Midnight
- how can i unserialize Symfony transport messages?
- How to change a queryset in Django?
- How to serialize object to JSON format which inherits IList and has other properties
- Json.stringify() is ignoring a object property after xlsx.sheet_to_json
- how to make aiogram.Message from telethon.Message
- implementin filter for vector of custom struct in RUST
- How to properly Serialize/Deserialize an ArrayList with Custom Objects?
- Append serialized objects to a single file and load Rust
Related Questions in FORMS
- How to add the dynamic new rows from my registration form in my database?
- how to play a sounds in c# forms?
- How can I prevent the password from appearing in the network tab payload?
- App script to prevent duplicate form submission
- php $_FILE variable undefined index
- Why are checkboxes not posted when unchecked?
- How do I integrate an existing delete function that is located in my routes.php file to a delete button in a modal in my hr.employees.profile.php?
- How to add default text in output to filled fields in Contact Form 7
- How to create yup schema for dynamic array of different objects
- How to Nest a TelerikGrid inside TelerikForm with Blazor
- How to customize woocommerce add to cart button position
- How to dynamically add two v-text-fields to a form when a button is clicked and uniquely identify them
- NG8003: No directive found with exportAs 'ngForm'. [plugin angular-compiler]
- single form and multiple submit (with multiple value)
- Receive AJAX Form data in Server side
Related Questions in JSONTEMPLATE
- Log4j Json Template Layout Config
- Delete azure resource group after 30 days of creation based on tags using azure policy
- IllegalAccessError in JsonTemplateLayout in log4j2
- What is the best way to debug a custom Squarespace JSON-T web application?
- Issue migrating from PatternLayout to JsonTemplateLayout, Null or empty MDC values does not appear in log
- How to establish connection between AWS account to outside services or application (which are not on AWS)
- How to create class for dynamic JSON structure in Spring Boot Java
- Jolt transformation while using IF ELSE map the keys to new keys and also use these replacement for new key value pair
- Using Mustache API to parse Elasticsearch JSON Template requests
- Azure VM Extension provisioning has taken too long to complete
- Squarespace Events by Month
- squarespace multiple index page styles
- infinite scroll on squarespace get category filter
- Is it possible to use json files as templates in Azure Data Factory through .Net SDK?
- JSON Template in Lua
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can serialize a form with $(form).serialize ()
I'm not sure what the element id has to do with anything, but they should be unique on a page.