Nested for loop with null errors
I'm having an issue with a nested for loop generating a null error.
Info:
- 8 text fields named reset#.#
- reset fields are numbered 1-8, followed by a dot "." then 2, 4, 6, or 8; these are not widget numbers
- reset1.2, reset2.2
- reset3.4, reset4.4
- reset5.6, reset6.6
- reset7.8, reset8.8
Here's what I'm getting in the console; it's giving me 8 object fields but 3-4 null returns between each:
for(var i = 1; i < 9; i++) {
var ary1 = ["2", "4", "6", "8"];
for(var j = 0; j < ary1.length; j ++) {
var cReset = getField("reset" + i + "." + ary1[j]);
console.println(cReset);
}
}
[object Field]
null
null
null
[object Field]
null
null
null
null
[object Field]
null
null
null
[object Field]
null
null
null
null
[object Field]
null
null
null
[object Field]
null
null
null
null
[object Field]
null
null
null
[object Field]
true
Here's what the code I'm trying to write says in the console; it's saying the field is null when I try and set the mouse up setAction, but the console IS showing 8 object fields. What am I doing wrong and how do I get rid of all the null returns?:
for(var i = 1; i < 9; i++) {
var ary1 = ["2", "4", "6", "8"];
for(var j = 0; j < ary1.length; j++) {
var cReset = this.getField("reset" + i + ary1[j]);
cReset.setAction("MouseUp", "resetForm([\"card' + i + '\"]);");
}
}
TypeError: cReset is null
5:Console:Exec
undefined
