I have a horizontal navigation. When you click a navigation link that has a child menu, this menu pops out to the side and the parent link gets a background-color applied to it. If the navigation link does not have a child menu, you are taken right to the page, but the active link should still get a background-color applied to it.
However, what is happening is, when I click on a childless link, a parent link above it gets the background applied to it instead of the link that was actually clicked. This happens in both IE and FF.
The navigation functions and the onClick functions correctly. However, the style is being applied in the wrong place.
Here's the javascript
:
-
function secondarymenuToggle(name,id) {
-
var eArray = document.getElementsByTagName('DIV');
-
var ele = document.getElementById(id);
-
-
for (i = 0; i < eArray.length; i++)
-
{
-
if (eArray[i].getAttribute('name') == name)
-
eArray[i].className="SecondaryMenu";
-
}
-
-
if (ele != undefined)
-
ele.className="SecondaryMenuActive";
-
-
}
-
Here's the php where it is being put into the page:
[PHP]
$link_before = "<a href=\"".$location_var.$option_link."&cbc=1&uspid= ".$option_id."\" CLASS=\"SecondaryMenu\">";
$link_after = "</a>";
$onclick = "onclick=\"displayMenu('".$option_id."', '".$divString."');\"";
$onclick_toggle = "onclick=\"secondarymenuToggle('levelone','levelon e".$levelone_counter."');secondarymenuToggle('leve ltwo','')\"";
echo "<tr $onclick>\n";
echo "<td><div class=\"SecondaryMenu\" $onclick_toggle name=\"levelone\" id=\"levelone".$levelone_counter."\">";
echo "<div class=\"SecondaryMenu\" >".$link_before.$image_var.$link_after.$link_befor e.$option_display_value.$link_after."</div>";
[/PHP]
It seems that maybe the loop is getting mixed up somewhere? I've troubleshot this quite a bit and am not really sure what is happening. If you would like me to better explain the problem, let me know. Unfortunately it is not publicly accessible.