Jump to content

showing and hidding divs


M.O.S. Studios

Recommended Posts

Hey,

  basically i have a menu that is two columns, clicking something on the left will show info on the right

 

I did this by adding all the info on the right menu and hidding it using css and div tags.

 

I then use a function to show them when the related button is clicked.

 

here is my code

 

the function

<script type="text/javascript">
function unhide(divID){
var item = document.getElementById(divID);
if(item){
	item.className='unhidden';
}
}
</script>

 

the following will show all info in between the tags <div id='1'></div>

 

<a href='javascript:unhide(1);'>

 

 

Here is the problem

i want to add an array that will hide all the tag listed in it,

 

for example:

 

<a href='javascript:unhide(4, array("1", "2", "3"));'>Season 1</a>

 

that will hide div tags with id 1, 2 and 3 and show div tag with id 4

 

I'm not quite sure how to add that to my function,

 

any help??

 

thanks in advance!

Link to comment
Share on other sites

you can pass an array like this to a function ...

 

<a href='javascript:unhide([1,2,3]);'>Unhide</a>

 

then for your function, just loop through each one, showing each...

 

function unhide(id_array)
{
    for(var i=0;i<id_array.length;i++)
        document.getElementById(id_array[i]).className='unhidden';
}

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.