Good Morning everybody,
I'm trying to adapt a tutorial script that will handle the behaviour of an
"Expanding/Contracting" site-navigation menu. The code that seems to
handle the expansion and contraction follows at the bottom of my
message here.
This following line is a big part of my hang-up:
document.getEle mentById('m1'). style.display=' none';
Question #1:
My "assumption " is that this statement line will "Contract" the menu-chain
that is named by 'm1' and the action word is 'none'.
My other 'assumption' is that the other statement line would " Expand" the
named menu-chain and the action word is 'block'.
That doesn't make sense but really, what do I know?
Am I correct in my assumptions?
Question #2: ( This is my biggie )
At the end of the day, I want the menu.shtml page to open with
this menu in a fully contracted state. Display only the major
category headings. I took all of the document.getEle mentById
statements and placed them in a function called CloseAll(), like this:
function CloseAll()
{
document.getEle mentById('m1'). style.display=' none';
document.getEle mentById('m2'). ... // did this for each menu-chain
}
Placed this tag in the menu.shtml
<BODY onLoad="CloseAl l()">
but...
When I load the page... nothing displays... NADA, ZILCH.
If I remove the onLoad part, he page displays, but the
menu is FULLY expanded.
Clearly, I am working this code wrong, can someone please help
me sort it out? I've been kicking this thing around for so long that
I barely remember to eat.
Many thanks
-Paul-
[ All of this in now located in the "JS" file ]
document.getEle mentById('m1'). style.display=' none';
document.getEle mentById('m2'). style.display=' none';
document.getEle mentById('m3'). style.display=' none';
document.getEle mentById('m4'). style.display=' none';
document.getEle mentById('m5'). style.display=' none';
document.getEle mentById('m6'). style.display=' none';
document.getEle mentById('m7'). style.display=' none';
document.getEle mentById('m8'). style.display=' none';
document.getEle mentById('m9'). style.display=' none';
var Ary=new Array();
function toggle(list){
var listElement=doc ument.getElemen tById(list);
for (i=0;i<Ary.leng th;i++){
if (Ary[i]!=listElement){
Ary[i].style.display= "none";
}
}
if (listElement.st yle.display=="n one"){
listElement.sty le.display="blo ck";
}
else {
listElement.sty le.display="non e";
}
if (!listElement.d is){
listElement.dis =1;
Ary[Ary.length]=listElement;
}
}
I'm trying to adapt a tutorial script that will handle the behaviour of an
"Expanding/Contracting" site-navigation menu. The code that seems to
handle the expansion and contraction follows at the bottom of my
message here.
This following line is a big part of my hang-up:
document.getEle mentById('m1'). style.display=' none';
Question #1:
My "assumption " is that this statement line will "Contract" the menu-chain
that is named by 'm1' and the action word is 'none'.
My other 'assumption' is that the other statement line would " Expand" the
named menu-chain and the action word is 'block'.
That doesn't make sense but really, what do I know?
Am I correct in my assumptions?
Question #2: ( This is my biggie )
At the end of the day, I want the menu.shtml page to open with
this menu in a fully contracted state. Display only the major
category headings. I took all of the document.getEle mentById
statements and placed them in a function called CloseAll(), like this:
function CloseAll()
{
document.getEle mentById('m1'). style.display=' none';
document.getEle mentById('m2'). ... // did this for each menu-chain
}
Placed this tag in the menu.shtml
<BODY onLoad="CloseAl l()">
but...
When I load the page... nothing displays... NADA, ZILCH.
If I remove the onLoad part, he page displays, but the
menu is FULLY expanded.
Clearly, I am working this code wrong, can someone please help
me sort it out? I've been kicking this thing around for so long that
I barely remember to eat.
Many thanks
-Paul-
[ All of this in now located in the "JS" file ]
document.getEle mentById('m1'). style.display=' none';
document.getEle mentById('m2'). style.display=' none';
document.getEle mentById('m3'). style.display=' none';
document.getEle mentById('m4'). style.display=' none';
document.getEle mentById('m5'). style.display=' none';
document.getEle mentById('m6'). style.display=' none';
document.getEle mentById('m7'). style.display=' none';
document.getEle mentById('m8'). style.display=' none';
document.getEle mentById('m9'). style.display=' none';
var Ary=new Array();
function toggle(list){
var listElement=doc ument.getElemen tById(list);
for (i=0;i<Ary.leng th;i++){
if (Ary[i]!=listElement){
Ary[i].style.display= "none";
}
}
if (listElement.st yle.display=="n one"){
listElement.sty le.display="blo ck";
}
else {
listElement.sty le.display="non e";
}
if (!listElement.d is){
listElement.dis =1;
Ary[Ary.length]=listElement;
}
}
Comment