I have an associative array where the keys are strings and the values are arrays on integers.
{"Remebering":[0,0,0,0,0,0,0,0,0,0,0],
"Understanding":[0,0,0,0,0,0,0,0,0,0,0],
"Analyzing":[0,0,0,0,0,0,0,0,0,0,0]}
I am looping through each object and then updating values in the array.
var rigorLabels = $('.subHeader', standardsTable);
var itemCounts = new Array($('.itemTypeLabel', standardsTable).length);
for (var i = 0; i < itemCounts.length; i++)
{
itemCounts[i] = 0;
}
var rigorArray = [];
for (var i = 1; i < rigorLabels.length; i++)
{
rigorArray[rigorLabels[i].innerHTML.toString()] = itemCounts;
}
$('.itemTypeLabel', standardsTable).each(function (itemIndex)
{
itemTypes += '"' + $(this).html() + '",';
var itemTypeName = $(this).html().replace(' ', '').replace('/', '');
$('.subHeader:not(:First)', standardsTable).each(function() {
var rigorName = $(this).html().toString();
var itemInput = $('#' + $(this).html() + '_' + itemTypeName + '_input');
if(typeof (itemInput.attr('value')) != 'undefined' && itemInput.attr('value') != '')
rigorArray[rigorName][itemIndex] = parseInt(itemInput.attr('value'));
});
});
Everything seems to be working in the above code except when I hit the code to update rigorArray. At this point I should be updating a single object and a single value in array of integers. The problem I'm having is that it's updating all objects. So if I'm trying to update the 2 position for the Remembering object, the update is setting the value in the second position for all objects, not just Remembering.