eon201 Posted November 30, 2007 Share Posted November 30, 2007 Hi Im trying to hide div classes with the following method: <script language="JavaScript"> function setVisibility(class, visibility) { document.getElementById(class).style.display = visibility; } </script> <input type=button name=type value='Today' onclick="setVisibility('a', 'inline'); setVisibility('b', 'none'); setVisibility('c', 'none'); setVisibility('d', 'none'); setVisibility('e', 'none');";> <div class="a"><?php //This is the today div ?>a</div> <div class="b"><?php //This is last (today) div ?>b</div> <div class="c"><?php //This is the last week avg div ?>c</div> <div class="d"><?php //This is this date last month div ?>d</div> <div class="e"><?php //This is the last month avg div ?>e</div> <div class="a"><?php //This is the today div ?>a</div> <div class="b"><?php //This is last (today) div ?>b</div> <div class="c"><?php //This is the last week avg div ?>c</div> <div class="d"><?php //This is this date last month div ?>d</div> <div class="e"><?php //This is the last month avg div ?>e</div> Now the problem is that, I have to use div class's so I can hide multiple divs (there are loads of these classes 6x each) but the code refuses to work. But it will work when there is only one class that the javascript is displaying/hiding. Why is this? Can I work around it? Thanks in advance. Eon201 Quote Link to comment Share on other sites More sharing options...
xenophobia Posted November 30, 2007 Share Posted November 30, 2007 Will that work? You should put id instead of class into your div tag: <div id="a">..</div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.