Forum Moderators: open

Message Too Old, No Replies

hide menus

         

jackvull

10:24 am on Oct 7, 2005 (gmt 0)

10+ Year Member



I have some CSS drop down menus. When someone clicks on one of the menus, I want to hide all the other menus for about 5 seconds and then re-display them.
I have some basic Javascript to do this:
function showhide(divname,disp) {
document.getElementById(divname).style.visibility=disp;
}

I then call this as follows:
<script language = "javascript" type="text/javascript">
//showhide('DJdiv<? echo $varDJID;?>','hidden');
showhide('DJdiv<? echo $DJDiv;?>','hidden');
function showMenus() {
showhide('DJdiv<? echo $varDJID;?>','');
}
setTimeout('showMenus()', 5000)
</script>

The problem is I don't know how to rnu this for all of the other menus. Would I need to load all the other menu divid's into an array?

It's also further complicated by the fact that each CSS menu has further drop downs, whioch do not seem to be hidden (probably because they do not have an id tag).

Any ideas?

jackvull

11:11 am on Oct 7, 2005 (gmt 0)

10+ Year Member



I have tidied this up to:
function brieflyHideMenus(varDJID) {
var DJDiv = 'DJdiv' + varDJID;
alert(DJDiv);
document.getElementById(DJDiv).style.visibility='hidden';

setTimeout("document.getElementById(globalDJDiv).style.visibility='visible'", 5000)
}

So, the function is called, but I need to call it for every div except the one that is clicked.

garann

8:41 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



I've needed to do this a few times, and I generally end up creating and looping through an array. I'm sure there's a better way, but I don't know it. It looks like your using some Perl or PHP thing to create your menus, and that they have the same name with a different number attached to the end. Is that right? If so, this might work:

function brieflyHideMenus(varDJID) {
for (var i=0;i<<? echo $NumberOfMenus;?>;i++) {
if (i!= varDJID) {
var DJDiv = 'DJdiv' + i;
alert(DJDiv);
document.getElementById(DJDiv).style.visibility='hidden';
setTimeout("document.getElementById(globalDJDiv).style.visibility='visible'", 5000)
}
}
}

(Forgive my lame attempt to write Perl. Hopefully you get my drift.)