Loop over array and set all vars to false or true in javascript
Posted
by Sixfoot Studio
on Stack Overflow
See other posts from Stack Overflow
or by Sixfoot Studio
Published on 2010-06-11T06:40:34Z
Indexed on
2010/06/11
6:52 UTC
Read the original article
Hit count: 194
JavaScript
|for-loop
Hi All,
I need to loop over my array and set all the vars to false or true. I have tried numerous options, none of which are working and it's clearly my lack of javascript syntax knowledge..Please take a look at this:
var closeAllCells = [IncomeOpen = "false",
RehabOpen = "false",
AttendantCareOpen = "false",
HomeMaintenanceOpen = "false",
DependantCareOpen = "false",
IndexationOpen = "false",
DeathFuneralOpen = "false",
ComprehensiveOpen = "false",
CollisionOpen = "false",
LiabilityOpen = "false",
DCPDOpen = "false"];
So my thinking is that I can just loop over this as follows
for (var i=0;i<closeAllCells.length;i++)
{
closeAllCells[i] = true; // or false if I wished
}
© Stack Overflow or respective owner