Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript/firebug skipping lines of code

Here's part of my code:

1  if (document.forms[0]["displayAddress"].value == "true") {
2    if (document.forms[0]["addressPresent"].value == "") {
3      $("#addressDiv").show();
4      document.forms[0]["addressPresent"].value = "true";
5    }
6  }

Why would firebug skip over line 3? - in dubug mode it doesnt even highlight that row, just skips to the next.

edit: to clarify, line 2 evaluates to true and the debugger goes straight to line 4 without executing line 3. I have tried a forced refresh.

update: the first time the page loads this JS works, after the page is reloaded again I get this problem

like image 733
Mark W Avatar asked May 29 '26 20:05

Mark W


2 Answers

Are you sure that the condition

(document.forms[0]["addressPresent"].value == "")

evaluates to true?

If it does and it just jumps to line 4, have you evaluated that it is actually executing line 3? It could be that the debugger in Firebug is skipping it. Have you tried to break on that line?

Try breaking on that line.

like image 157
jakx Avatar answered May 31 '26 10:05

jakx


I've had Firebug act a little wonky with me at times. Usually a complete closing of Firefox and Firebug will fix the problem. If you need a second opinion, try Chrome's debugger.

like image 27
JoshNaro Avatar answered May 31 '26 11:05

JoshNaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!