So I’m continuing the problem of my coldfusion array building.
What I’ve got is a series of checkboxes in a form. What I need to do is take any checked (or ‘on’) items and create a comma-sep list of the names of the variables.
I attempted to use an if(isdefined…){ add to an array } but it’s not working as planned. Here’s the code I’m using:
-
checkedItems = ArrayNew(1); if(isdefined("form.heat1")){
-
-
checkedItems[1] = "heat1";
-
-
}
-
-
if(isdefined("form.heat2")){
-
-
checkedItems[2] = "heat2";
-
-
}
-
-
if(isdefined("form.heat3")){
-
-
checkedItems[3] = "heat3";
-
-
}
-
-
if(isdefined("form.tied")){
-
-
checkedItems[4] = "tied";
-
-
}
-
-
if(isdefined("form.notcontested")){
-
-
checkedItems[5] = "notcontested";
-
-
}
-
-
if(isdefined("form.handtimed")){
-
-
checkedItems[6] = "handtimed";
-
-
}
-
-
if(isdefined("form.preliminaries")){
-
-
checkedItems[7] = "preliminaries";
-
-
}
-
-
if(isdefined("form.meetrecord")){
-
-
checkedItems[8] = "meetrecord";
-
-
}
-
-
if(isdefined("form.schoolrecord")){
-
-
checkedItems[9] = "schoolrecord";
-
-
}
-
-
if(isdefined("form.staterecord")){
-
-
checkedItems[10] = "staterecord";
-
-
}
The problem is, when I run through that if list, I end up with #1 as ‘heat1′ and #6 as ‘handtimed’ and 2-5 will be “[undefined array element].”





Categories