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 Link to comment https://forums.phpfreaks.com/topic/79527-hiding-divs-with-javascript/ 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> Link to comment https://forums.phpfreaks.com/topic/79527-hiding-divs-with-javascript/#findComment-402894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.