View Full Version : 2 divs out of six won't show up with show/hide

06-14-2007, 05:20 PM
Hello. I've got two divs that won't work with the ShowContent / HideContent
Javascript function, but the others work fine. I've gone over and over the lines for typos, unclosed brackets, etc., and I can't find any. My header function is this:

script type="text/javascript" language="JavaScript"><!--
function HideContent(d) {
document.getElementById(d).style.display = "none";
function ShowContent(d) {
document.getElementById(d).style.display = "block";
function ReverseContentDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }

...my line commands (in a href links) are like this:

javascript:ShowContent('Goalx'); HideContent('Goal2'); HideContent('StrategicPlan'); HideContent('Vision'); HideContent('Mission') HideContent('Goal3'); HideContent('Goal4'); HideContent('Goal5'); HideContent('Goal6')"

...and my style in my (absolutely positioned) divs includes "display: none;" in all cases.

What am I doing wrong? 7 out of 9 links show and hide fine. The other two ('Goalx') and ('Goal3') don't show at all. I'm completely stumped. Any help would be HUGELY appreciated. Thanks, jb.

06-14-2007, 05:26 PM
Have you used a same id value for two different divs? (If so you will get some error)

Or sometimes these two divs are positioned below others.

06-14-2007, 05:41 PM
All my IDs are unique. As far as positioning goes, I have no z-index value for any of them. Is that a problem? Also, I was wondering about spacing - does the height value have to be exactly right or something? I've been at this a couple of days now. Arg! I appreciate your help.

06-14-2007, 06:45 PM
You missed the semicolon between 'Mission' and 'Goal3'.

javascript:ShowContent('Goalx'); HideContent('Goal2'); HideContent('StrategicPlan'); HideContent('Vision'); HideContent('Mission'); HideContent('Goal3'); HideContent('Goal4'); HideContent('Goal5'); HideContent('Goal6')
Check the Javascript console for error messages.

06-14-2007, 07:17 PM
Boy do I feel silly.

Thank you guys so much! Next time I'll have a real coding question instead of just typos. You guys rock. Next!