Context: The following function is called within a loop that is iterating through all of the inputs in a form.
collectCurrentSetting = function(index, element) {
element = $(element);
var name = element.attr('name');
var value = element.val();
currentValues[name] = value;
}
There is a section in that form that contains multiple inputs that use brackets in the name attribute to annotate that they belong as a part of an array. For sake of argument, let's say they are attributes of a person like so:
people[0][firstName]
people[0][lastName]
people[1][firstName]
people[2][lastName]
The goal is that it should create something like this:
currentValues[people][0][firstName] = 'jimbo';
It is technically, in that format, but it's treating everything in the brackets like a single key. And once it gets sent to the server it looks something like this:
currentValues["people[0][firstName"] = 'jimbo';
Question: How do I get it to properly parse these values and store them as an array in the currenValues variable?