I have some <inputs> that are dynamically created, and when checked they create a dynamic array, which gets stuffed into an .ajax post. All of it works with the exception of the dynamically created array. If I manually create the array it works fine, I'm just having trouble creating it dynamically. The numbers used in the ID (infoID1, infoID2, infoID3) and Values (1,2,3) are created via a PHP loop (infoID{$x}).
Sample inputs
<input id="infoID1" type="checkbox" value=1/>
<input id="info1" type="text" value="something good"/>
<input id="infoID2" type="checkbox" value=2/>
<input id="info2" type="text" value="something bad" />
<input id="infoID3" type="checkbox" value=3/>
<input id="info3" type="text" value="something ugly" />
The below dataArray is where I'm having all kinds of problems. I need to put both the ID and Value of the checked boxes in this dynamically created dataArray (using some type of loop) and add sequential numeric values to both the ID variable (infoID + 1 becomes infoID1) and the values (1,2,3)
so it will end up looking like this...
var dataArray = {
infoID1 : 1,
info1 : "something good",
infoID2 : 2,
info2 : "something bad",
infoID3 : 3,
info3 : "something ugly"
};
The dataArray then gets stuffed into the .ajax post below. The .ajax section is working fine.
$.ajax({
url: "workingPage.php",
data: dataArray,
type: 'POST',
success: function (otherData) {
$(doStuff);
}
});
Any help is appreciated!