| px | top | add code | search | signup | login | help |
<!-- Requires the "hierMenus.js" file, found at: www.dhtmlab.com. !-->
<!-- Copyright (c) 1999 by Zebadiah Kimmel, zkimmel@earthlink.net.!-->
<!-- All Rights Reserved. !-->
<!-- Feel free to reuse this code, but please give me credit somewhere. !-->
<!-- (Note that the hierMenus code requires credit too--see "hierMenus.js" for details.) !-->
<!-- This file creates hierarchical dropdown menus. Put it into the same
directory as "hierMenus.js" (downloaded from: www.dhtmlab.com) and
a triangle image called "tri.gif". Then load this file into PHP3. !-->
<?php
// creates the javascript code for a hierarchical menu
// requires a menu identifier and three arrays (all the same size) as input
// warning: if a name or an href contains a single quote ', things will go wrong
// (this just means you should backslash any single quotes)
// identifier 1 means menu number 1, 2 means menu number 2, etc (in which case title is used)
// identifier 1_1 means submenu 1 of menu 1
// identifier 1_2 means submenu 2 of menu 1
// identifier 3_4_1 means submenu 1 of submenu 4 of submenu 3
// and so on
function buildMenu($identifier, $name, $href, $submenu, $title="")
{
echo "<script> ";
echo "\n";
$num=count($name);
if (strchr($identifier,"_"))
echo "arMenu" . $identifier . " = new Array(";
else
{
// modify the hex (#RRGGBB) numbers to get different colors
echo "arMenu" . $identifier . " = new Array(null, 0, 0, '#000000','#000000', '#00FFFF','#FFFF00', '#008888','#008888'";
if ($num>0)
echo ",";
else
echo ",'None','javascript:hideAll();',0";
}
for($i=0; $i<$num; $i++)
{
$n=$name[$i];
$h=$href[$i];
$s=$submenu[$i];
echo "'$n','$h',$s";
if ($i<$num-1)
echo ",";
}
echo "); ";
echo "\n";
echo "</script> ";
echo "\n";
if (!(strchr($identifier,"_")))
{
echo "<A CLASS=leftMenuMore HREF='javascript:void(0)' ";
echo "onMouseOver='popUp(\"elMenu".$identifier."\",event)' onMouseOut='popDown(\"elMenu".$identifier."\")'> ";
echo "$title";
echo "<IMG SRC='triangle.gif' WIDTH=10 HEIGHT=10 BORDER=0 ALT=''></A>";
}
}
// Modify the following for your own application.
$name=array("CNN","Tribune","NY Times");
$href=array("http://cnn.com", "javascript:alert(\'hello\')", "http://nytimes.com");
$submenu=array(1,0,1);
buildMenu("1",$name,$href,$submenu, "Click on me");
$name=array("Washington Post","Mercury Star","Wall St Journal");
$href=array("http://washingtonpost.com", "javascript:alert(\'aloha\')", "http://wsj.com");
$submenu=array(0,0,1);
buildMenu("1_1",$name,$href,$submenu);
$name=array("Star Wars");
$href=array("http://starwars.com");
$submenu=array(0,0,0);
buildMenu("1_1_3",$name,$href,$submenu);
$name=array("Apple","IBM","Dell");
$href=array("http://apple.com", "http://ibm.com", "http://dell.com");
$submenu=array(0,0,0);
buildMenu("1_3",$name,$href,$submenu);echo "<P>";
$name=array("Mattel", "Hasbro");
$href=array("http://mattel.com", "http://hasbro.com");
$submenu=array(0,1);
buildMenu("2",$name,$href,$submenu, "Click on me also");
$name=array("Lego");
$href=array("http://lego.com");
$submenu=array(0);
buildMenu("2_2",$name,$href,$submenu);
?>
<script>
// define default values
// (some colors are built into the code above, so if you want
// to change them you need to change their values above)
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac));
function popUp(){return};
function popDown(){return};
function startIt(){return};
if (!ver4) event = null;
menuVersion = "4.0b0.1";
menuWidth = 120;
childOverlap = -5;
childOffset = 0;
perCentOver = null;
secondsVisible = .5;
fntCol = "blue";
fntSiz = "9";
fntBold = true;
fntItal = false;
fntFam = "MS Sans Serif,sans-serif";
backCol = "#CE9A9C";
overCol = "maroon";
overFnt = "white";
borWid = 2;
borCol = "yellow";
borSty = "solid";
itemPad = 3;
// you can change the next variable to point to any image you like
imgSrc = "tri.gif"; // triangle image
imgSiz = 10;
separator = 2;
separatorCol = "maroon";
isFrames = false;
keepHilite = true;
NSfontOver = true;
clickStart = true;
clickKill = true;
showVisited = "yellow";
menusOn = true;
</script>
<!-- load the hierMenus.js source file !-->
<script src="hierMenus.js"></script>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.