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
https://forums.phpfreaks.com/topic/174366-showing-and-hidding-divs/
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';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.