hessodreamy
Programmer
I am creating a pop-up menu/submenu thingy by using a function to read from an array containing info on the submenus, and dynamically attaching a div containing submenu hyperlinks to the menu item. Make sense?
All is working fine except that the hyperlinks don't work (OK i guess that's not working fine at all). The menu pops up with the right items, and the status bar shows the right urls for the submenus, but they dont take you to the link. However right-clicking on a submenu and opening in new window does. Confusing. Also I have defined an a:hover class in the stylesheet which the submenus dont respond to. So are they hyperlinks or aren't they? And how do I get them to follow the link, and display as they should on hover? Anyway, let's see some code:
Here's the html showing the main menu items
And here's the array containing the submenu information:
All is working fine except that the hyperlinks don't work (OK i guess that's not working fine at all). The menu pops up with the right items, and the status bar shows the right urls for the submenus, but they dont take you to the link. However right-clicking on a submenu and opening in new window does. Confusing. Also I have defined an a:hover class in the stylesheet which the submenus dont respond to. So are they hyperlinks or aren't they? And how do I get them to follow the link, and display as they should on hover? Anyway, let's see some code:
Code:
function addMenu(id)
//function for creating submenu div
{
var mainMenu = document.getElementById(id);
var subMenu = document.createElement("<div id='mycatSubMenu' class='subMenu'>");
var sublist = cats[id];
//for each subcat
//create link
//set href
//set inner text
//add to sub
var count = sublist.length;
for(i=0; i<count;i++){
var link = document.createElement('a');
// link.href= '/products/category.php?catid='+count;
link.href='/products/category.php?catid='+i;
link.appendChild(document.createTextNode(sublist[i]));
subMenu.appendChild(link);
}
mainMenu.appendChild(subMenu);
}
Here's the html showing the main menu items
Code:
<div id="223" style="position:relative" onmouseover="addMenu(id)"><a name="Accounting Book/Pa..." href="../products/category.php?catid=223"> < Accounting Book/Pa...</a></div>
<div id="224" style="position:relative" onmouseover="addMenu(id)">
<a name="Adhesives" href="../products/category.php?catid=224"> < Adhesives</a></div>
<div id="136" style="position:relative" onmouseover="addMenu(id)">
<a name="Air Care Germokill" href="../products/category.php?catid=136"> < Air Care Germokill</a></div>
<div id="183" style="position:relative" onmouseover="addMenu(id)">
<a name="Air Conditioners" href="../products/category.php?catid=183"> < Air Conditioners</a></div>
And here's the array containing the submenu information:
Code:
<script>var cats = new Array();
cats[195] = new Array('Chemical Absorbents','General Purpose Absorbents','Oil Only Absorbents','Spill Kits');
cats[223] = new Array('Analysis ruled pad','Analysis ruled paper','General Trader/VAT book','Halfbound account book','Postage & Delivery book','Standard account book','Standard Analysis Book','Wage & S.S.P book');
cats[224] = new Array('All Purpose adhesive','Dry adhesive','Glue Roller/Refill','Glue Stick/Gluepen','Paste/Smooth');
cats[136] = new Array('Air Purifiers (Germokill)');
cats[183] = new Array('Air Conditioners','Air free Air Purifier');
</script>