document.getElementById(a_div_id) is null
By setting breakpoints in the script I quickly determined that, not surprisingly, the variable
a_div_idreferred to the
document.getElementById("line_items").style.display = 'block';
fully expecting to see the
id=line_itemsto pop up.
Nope! Nothing but silence. The next port of call was the HTML source of the page in question. Sure enough, I was able to locate the
divin question. However, the syntax highlighting showed that the entire
divwas commented out!!!! So, my script was correct in saying that there was no such element in the document.
Turns out that culprit was the use of textual em-dashes1 in my comments. Typically em-dashes are represented in text as two consecutive hyphens thusly
WYSIWYG editors (such as MS Word) are wont to convert that into a single em-dash
However, there is no such implicit conversion in a JSP or HTML page. So there it was smack in the middle of the comment.
<!-- This is bad news –– if you ask me. -->
It colluded with other such comments on the page to make a mess of what
divs were actually there. I know HTML wonks out there are going to chime-in in unison with a "Well, D'uuuuh! Don't you know that that's improper HTML syntax". OK, for the rest of us, the Web Design group provides a pithy maxim to code by
An HTML comment begins with "<!--", ends with "-->" and does not contain "--" or ">" anywhere in the comment.
The formal definition of an HTML comment can be found at W3C.
My peeve now is that you would think that a self-respecting IDE like Eclipse2 would point that out for you. Now that I think back, even a puny little editor like VIM would flag this error. Heck, Eclipse doesn't even acknowledge
All this is coming at the end of what has been a long week of futzing with Eclipse's sloppy handling of JSPs in general. Yes, this is with an Eclipse that is souped up to use the Eclipse Web Tools Project (WTP) "goodness".
1 em-dashes (—) Denotes a pause in thought, a parenthetical statement, or — more casually — an afterthought. For more on this subject, see What’s the Difference Between an Em Dash, En Dash & Hyphen?. BTW, did you know that an em-dash is called that because it is the width of a an 'm' in the current font? Useless trivia.
2 For the record, I am using the latest version 3.4.x (Ganymede).