M.O.S. Studios Posted September 15, 2009 Share Posted September 15, 2009 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 More sharing options...
fooDigi Posted September 15, 2009 Share Posted September 15, 2009 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 https://forums.phpfreaks.com/topic/174366-showing-and-hidding-divs/#findComment-919126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.