Is this me going mad or have I missed something stupid here?
Here is the code:
(function showErrors() {
if((typeof errorObj) == 'object') {
var alertStr = "Errors found: \n\n";
for(prop in errorObj) {
var element = document.getElementById(prop);
element.style.border = '#FF0000 2px solid';
//alert(errorObj[prop]);
alertStr += errorObj[prop] + "\n";
}
alert(alertStr);
}else {
alert('none');
}
})();
This function executes no problem as the border styling works as does the alert that is currently commented out. The thing that isn't working is the alert(alertStr) part of the code (line 10) at the end of the for in loop. My browser won't alert the string that has been built in the loop.
Any ideas?
EDIT: After some more playing around with it. It seems that any code after the for in loop does not execute, which is strange as I thought JS ran top to bottom?
This post has been edited by RyanRobinson: 19 September 2012 - 03:26 PM

New Topic/Question
Reply



MultiQuote




|