Re: A problem with an apparently common JS menu...
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: A problem with an apparently common JS menu...

From: Bryan <j_oswalt@bellsouth.net>
Date: Tue Nov 15 2005 - 23:19:05 CET

OK, I have set up the menu like so:

<SCRIPT LANGUAGE="JavaScript">

// ADDITIONAL NOTES
// The input variables to the toggle function are the number of the
submenu to open/close,
// starting with 0, and the number of pixels to move the objects below.
// For example toggle(1,60) opens/closes the second submenu and moves
the objects below 60 pixels.

var nom = 10; // Number of menus
var usePictures = 0; // use pictures? 1 = yes, 0 = no

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.getElementById) {
visible = 'visible';
hidden = 'hidden';
}
for (var i = 1; i <= nom; i++) {
ttls[i] = ('title' + i);
subs[i] = ('submenu' +i);
}
function picopen(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getElementById) {
document.getElementById(pic).src = "opened.gif";
   }
}
function picclose(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getElementById) {
document.getElementById(pic).src = "closed.gif";
   }
}
lastn = (nom + 1);
lastmove = 0;
function lasttoggle(n,move) {
if (n <= nom) {
menu = ('submenu' + n);
if (document.getElementById) {
submenu = document.getElementById(menu).style;
}
if (submenu.visibility == visible) {
submenu.visibility = hidden;
for (var i = (n+1); i <= nom; i++) {
if (document.getElementById) {
document.getElementById(ttls[i]).style.pixelTop -= move;
document.getElementById(subs[i]).style.pixelTop -= move;
            }
         }
      }
   }
}
function toggle(n,move) {
menu = ('submenu' + n);
if (document.getElementById) {
submenu = document.getElementById(menu).style;
}
if (submenu.visibility == visible) {
submenu.visibility = hidden;
if (usePictures) picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.getElementById) {
document.getElementById(ttls[i]).style.pixelTop -= move;
document.getElementById(subs[i]).style.pixelTop -= move;
      }
   }
}
else {
submenu.visibility = visible;
if (usePictures) picopen(n);
if (lastn != n) {
lasttoggle(lastn,lastmove);
}
for (var i = (n+1); i <= nom; i++) {
if (document.getElementById) {
document.getElementById(ttls[i]).style.pixelTop += move;
document.getElementById(subs[i]).style.pixelTop += move;
      }
   }
}
lastn = n;
lastmove = move;
}

function loadFrames(frame1,page1) {
eval("parent."+frame1+".location='"+page1+"'");
}

// End -->

</script>

The drop downs works, but I have the problem of the menu not making
room... maybe I'm barking up the wrong tree, so here's and example of
the code for one of the submenus:

<div class="title" id="title3" style="top: 40px;">
<a href="alumavault/index.html" Target=main onclick="javascript:
toggle(3,80); loadFrames('main', 'alumavault/index.html'); return
false">
Curved Metal Ceilings</a>
</div>

<div class="submenu" id="submenu3" style="top: 55px; height:48">
 <a href="alumavault/av1000.html" target="main">System
1000/2000</a><br>
 <a href="alumavault/av3000.html" target="main">System 3000</a><br>
 <a href="alumavault/perimeters.html" target="main">Perimeters</a><br>
 <a href="alumavault/options.html" target="main">Options</a><br>
 <a href="alumavault/details.htm" target="main">Product Data</a><br>
 <a href="Gallerybackup/gallery.htm#curved metal ceilings"
target="main">Gallery</a>
</div>

Basically, the beginning part is supposed to toggle the menu a specific
number of pixels... so if the menu isn't toggling, maybe the JS isn't
the problem, but the submenu code...
Received on Mon Nov 21 03:30:41 2005