Dump your variables
When you know what line is causing the error, but you cannot see an immediate reason for the error, dump all the variables that are involved. When we say "dump", we simply mean to show the current content or value of the variables. For instance, if we were not getting into a loop, we might do this:
alert("myArray.length: " + myArray.length);
for (var x=0; x < myArray.length; x++) {
alert("x: " + x);
test.innerHTML = test.innerHTML + "" + myArray[x] + "";
}
Because we are checking the length of the array in the loop, we want to check how many elements the array has. If we get zero back, then we know we are never getting into the array ( 0 is not less than zero, so we have a false condition, which exits the loop).
When you can not see anything wrong with your code, the problem is probably in the data being used. So check those values.
- Printer-friendly version
- Login or register to post comments

hello
You are absolutely right !!!