Jump to content

hiding divs with javascript


eon201

Recommended Posts

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 ;D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.