Click to See Complete Forum and Search --> : Function/Div code


vik_pa
04-30-2003, 10:36 AM
I have obtained the following piece of code, and what it does is when a menu item is selected (when it has a + besides it) a sub menu appear beneath it... (i'm sure you have all encountered this) However I do not understand the function code and what the DIV tag does. See bold below:



function swapMenu(text,content,refimage){
var mystring = refimage.src;
var ref_id = refimage.id;
if(mystring.search(/expand.gif/i)>0){
document.images[ref_id].src = "../Images/contract.gif";
}else if(mystring.search(/contract.gif/i)>0){
document.images[ref_id].src = "../Images/expand.gif";
}
temporary.innerHTML=content.innerHTML;
content.innerHTML = text.innerHTML;
text.innerHTML = temporary.innerHTML;
temporary.innerHTML="";
}

<Div id = "temporary" CLASS = "DivMenu"></DIV>
<img id="benmeasureimage" src="../Images/expand.gif" onclick="swapMenu(benmeasurediv,benmeasurecontent,benmeasureimage)"><A href="javascript: swapMenu(benmeasurediv,benmeasurecontent,benmeasureimage)" class="clSubbBold">
Benefit Measurement</A>
<DIV id="benmeasurediv" CLASS="DivMenu">
<li><A href='benmeasure_01.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Benefit Measurement</A><BR>
<li><A href='benmeasure_02.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Target Date</A><BR>
<li><A href='benmeasure_03.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Was Benefit achieved</A><BR>
<li><A href='benmeasure_04.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Metric</A><BR>
<li><A href='benmeasure_05.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Method</A><BR>
<li><A href='benmeasure_06.htm' target='main' class='ClSubb'>&nbsp;&nbsp;&nbsp;Police Force</A><BR>
&nbsp;
</DIV>
<DIV id="benmeasurecontent">&nbsp;</DIV>

gil davis
04-30-2003, 11:33 AM
Without the CSS that goes along with the class="DivMenu", we can only guess. Someone went to a lot of (unnecessary) trouble to move the contents of one div with a certain style, into another div with no style at all.