Guest User

Untitled

a guest
Dec 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var group_fields = [];
  2. // Loop through the fields
  3. theForm.serializeArray().forEach(function(entry,i) {
  4. // Get the index and prop name from the entry name
  5. var nameparts = /^([a-zA-Z0-9_]+)\[(.+)\]\[(.*)\]$/.exec(entry.name);
  6. // Get the group entry if we already have it
  7. var group = group_fields[nameparts[2]];
  8. if (!group) {
  9. // We don't, create and add it
  10. group = group_fields[nameparts[2]] = {};
  11. }
  12. // Set the property (address, street, etc.)
  13. group_fields[nameparts[2]][nameparts[3]] = entry.value;
  14. });
Add Comment
Please, Sign In to add comment