turtleman2009
asked on
Using Array object as variable name
I am looping through a large array and the value in one of the array objects will be the name of another variable on the page. I need to be able to write the array object but have the value processed as a variable name to pull the variables value.
Is this possible? If so how would I go about accomplishing it?
Is this possible? If so how would I go about accomplishing it?
var Date17000 = "Jan 2014"
var Date23000 = "Feb 2014"
var projectsArray =
[
{ "Fund": "Project A",
"Designation": "17000",
"YearDes": Date17000,
"Title": "General",
"AmountAsked": "0.00",
"UpdateSent": "",
},
{ "Fund": "Project B",
"Designation": "23000",
"YearDes": Date23000,
"Title": "Restricted",
"AmountAsked": "460.00",
"UpdateSent": "",
}
]
for(var i=0;i<projectsArray.length;i++) {
var obj = projectsArray[i];
if (obj.YearDes == "Jan 2014") { var Jan2014 = Jan2014 + 1;
}
else if (obj.YearDes == "Feb 2014") { var Feb2014 = Feb2014 + 1;}
}
ASKER
I probably didn't explain it well. Sorry about that.
The problem is I have an array that has all the information for individual product entries, the only thing it does not have included is the date. The dates are exported into another file as variables. But I need to be able associate each array entry with it's appropriate date from the list of variables so I can produce monthly and yearly reports about the amount of items as well as combined profit from each type of item.
The problem is I have an array that has all the information for individual product entries, the only thing it does not have included is the date. The dates are exported into another file as variables. But I need to be able associate each array entry with it's appropriate date from the list of variables so I can produce monthly and yearly reports about the amount of items as well as combined profit from each type of item.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help
Open in new window