djr
09-22-2010, 03:57 PM
I trying to do something that is very simple in most any language,
but its behavior in javascript is very strange - probably because of my poor understanding of scope, etc.
[CODE]
while (tableA.next()) {
while (tableB.next()) {
var a_field1 = tableA.field1.toLowerCase();
var b_field1 = tableB.field1.toLowerCase();
if (b_field1 == a_field1) {
var a_field2 = tableA.field2.toLowerCase();
var b_field2 = tableB.field2.toLowerCase();
if (b_field2 == a_field2) {
matched_field2 = b_field2;
}
}
}
}
[CODE]
I find a match and matched_field2 is assigned.
The next one matchs on field1 but not field2
but it still re-assigns matched_field2 !!
but its behavior in javascript is very strange - probably because of my poor understanding of scope, etc.
[CODE]
while (tableA.next()) {
while (tableB.next()) {
var a_field1 = tableA.field1.toLowerCase();
var b_field1 = tableB.field1.toLowerCase();
if (b_field1 == a_field1) {
var a_field2 = tableA.field2.toLowerCase();
var b_field2 = tableB.field2.toLowerCase();
if (b_field2 == a_field2) {
matched_field2 = b_field2;
}
}
}
}
[CODE]
I find a match and matched_field2 is assigned.
The next one matchs on field1 but not field2
but it still re-assigns matched_field2 !!