Hey folks, so I ripped a basic dropdown menu template from javascript-array.com and I'm trying to get it to do a dropdown menu within a dropdown menu, and I've messed around with it and I'm lost.
Here's all the code.
Javascript:
Quote (<head>)
<link type="text/css" href="style.css" rel="stylesheet" />
<script>
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();
// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';
}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}
// close layer when click-out
document.onclick = mclose;
</script>
The HTML:
Quote (<body>)
<ul id="sddm" class="mlddm">
<li>
<a href="#"
onmouseover="mopen('m1')"
onmouseout="mclosetime()">
Timeframe [Dropdown Menu]
</a>
<div id="m1"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#"
onmouseover="mopen('m1')"
onmouseout="mclosetime()">
2015
</a>
<div id="m1"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="#">
January
</a>
</div>
<a href="#">
2016
</a>
<a href="#">
2017
</a>
</div>
</li>
</ul>
And the CSS in a different file if it matters:
Quote (style.css)
#sddm
{ margin: 0;
padding: 0;
z-index: 30
}
#sddm li
{ margin: 0;
padding: 0;
list-style: none;
float: left;
font: bold 11px arial
}
#sddm li a
{ display: block;
margin: 0 1px 0 0;
padding: 4px 10px;
width: 60px;
background: #5970B2;
color: #FFF;
text-align: center;
text-decoration: none
}
#sddm li a:hover
{ background: #49A3FF
}
#sddm div
{ position: absolute;
visibility: hidden;
margin: 0;
padding: 0;
background: #EAEBD8;
border: 1px solid #5970B2
}
#sddm div a
{ position: relative;
display: block;
margin: 0;
padding: 5px 10px;
width: auto;
white-space: nowrap;
text-align: left;
text-decoration: none;
background: #EAEBD8;
color: #2875DE;
font: 11px arial
}
#sddm div a:hover
{ background: #49A3FF;
color: #FFF
}
Basically, I'm trying to have a menu that has this kind of tier system:
2015
---January
--------1
--------2
--------3
--------etc...
---February
---March
---etc...
2016
2017
etc...
So far, the first tier drops down (in other words, when I hover over Timeframe [Dropdown Menu], I see 2015, 2016, and 2017). But when I try and hover over 2015, January doesn't pop up.
Anyone notice any glaring errors or have any input? Thanks!