Submenus in table cells

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrewkooi

    #1

    Submenus in table cells

    Greetings,

    I have 16 links for my horizontal menu navigation as you can see in my
    website www.singakad.com and at present, I am using a table and
    javascript for this menu.

    Is it possible for me to create a submenu for certain cells in this
    horizontal menu? How do I go about doing this?

    Thank you in advance for any assistance given.


    Regards,

    Andrew
  • Thomas Hoheneder

    #2
    Re: Submenus in table cells

    Hello,

    one simple idea would be the following one. I've just done it from the
    sratch.
    The idea is to place a div tag for each submenu which is invisible by
    default. When clicking on the text of a menu, the corresponding sub menu div
    tag is set visible. When clicking on a sub menu item, its number is
    displayed by an alert().
    When clicking another main menu item, all sub menus are set invisible,
    because I guess you always want just ONE sub mneu being visible at the same
    time.

    Possibly the following aspects are still open now (which I didn't care):
    1) There are div tags used, so it might be NO cross browser solution
    2) I used absolute positions for the div's, but on your web site your menus
    are centered on the page. So you have to find out another way to get the
    right coordinates for placing the div's.

    Here is the code:


    <html>
    <head>
    <title>Test</title>
    <style type="text/css">
    td {font-family:Arial;fo nt-size:10px;color :#ffffff;}
    </style>
    <script language="JScri pt" type="text/jscript">
    <!--
    function hideSubMenus()
    {
    document.all.me nu1.style.visib ility="hidden";
    document.all.me nu2.style.visib ility="hidden";
    document.all.me nu3.style.visib ility="hidden";
    document.all.me nu4.style.visib ility="hidden";
    document.all.me nu5.style.visib ility="hidden";
    document.all.me nu6.style.visib ility="hidden";
    }
    function showSubMenu(men u)
    {
    hideSubMenus(); // some other menu could be still visible now
    switch (menu)
    {
    case 1: document.all.me nu1.style.visib ility="visible" ; break;
    case 2: document.all.me nu2.style.visib ility="visible" ; break;
    case 3: document.all.me nu3.style.visib ility="visible" ; break;
    case 4: document.all.me nu4.style.visib ility="visible" ; break;
    case 5: document.all.me nu5.style.visib ility="visible" ; break;
    case 6: document.all.me nu6.style.visib ility="visible" ; break;
    }
    }
    function executeLink(sub item)
    {
    var menu = Math.round(subi tem / 10);
    alert("Sub menu item " + subitem + " was clicked.");
    switch (menu)
    {
    case 1: document.all.me nu1.style.visib ility="hidden"; break;
    case 2: document.all.me nu2.style.visib ility="hidden"; break;
    case 3: document.all.me nu3.style.visib ility="hidden"; break;
    case 4: document.all.me nu4.style.visib ility="hidden"; break;
    case 5: document.all.me nu5.style.visib ility="hidden"; break;
    case 6: document.all.me nu6.style.visib ility="hidden"; break;
    }
    }
    //-->
    </script>
    </head>
    <body leftmargin="10" topmargin="10">
    <table border="0" cellpadding="0" cellspacing="0" width="242">
    <tr height="20">
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(1)"
    style="cursor:h and">&nbsp;Men u 1</span></td>
    <td width="1"></td>
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(2)"
    style="cursor:h and">&nbsp;Men u 2</span></td>
    <td width="1"></td>
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(3)"
    style="cursor:h and">&nbsp;Men u 3</span></td>
    </tr>
    <tr height="1">
    <td width="1"></td>
    </tr>
    <tr height="20">
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(4)"
    style="cursor:h and">&nbsp;Men u 4</span></td>
    <td width="1"></td>
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(5)"
    style="cursor:h and">&nbsp;Men u 5</span></td>
    <td width="1"></td>
    <td width="80" bgcolor="#00009 9"><span onClick="showSu bMenu(6)"
    style="cursor:h and">&nbsp;Men u 6</span></td>
    </tr>
    </table>
    <div id="menu1"
    style="position :absolute;left: 10px;top:31px;v isibility:hidde n;cursor:hand;" >
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(11)">&nbs p;Sub item 1.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(12)">&nbs p;Sub item 1.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(13)">&nbs p;Sub item 1.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    <div id="menu2"
    style="position :absolute;left: 91px;top:31px;v isibility:hidde n;cursor:hand;" >
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(21)">&nbs p;Sub item 2.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(22)">&nbs p;Sub item 2.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(23)">&nbs p;Sub item 2.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    <div id="menu3"
    style="position :absolute;left: 172px;top:31px; visibility:hidd en;cursor:hand; "[color=blue]
    >[/color]
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(31)">&nbs p;Sub item 3.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(32)">&nbs p;Sub item 3.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(33)">&nbs p;Sub item 3.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    <div id="menu4"
    style="position :absolute;left: 10px;top:52px;v isibility:hidde n;cursor:hand;" >
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(41)">&nbs p;Sub item 4.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(42)">&nbs p;Sub item 4.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(43)">&nbs p;Sub item 4.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    <div id="menu5"
    style="position :absolute;left: 91px;top:52px;v isibility:hidde n;cursor:hand;" >
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(51)">&nbs p;Sub item 5.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(52)">&nbs p;Sub item 5.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(53)">&nbs p;Sub item 5.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    <div id="menu6"
    style="position :absolute;left: 172px;top:52px; visibility:hidd en;cursor:hand; "[color=blue]
    >[/color]
    <table border="0" cellpadding="0" cellspacing="0" width="80">
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(61)">&nbs p;Sub item 6.1</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(62)">&nbs p;Sub item 6.2</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    <tr height="20"><td width="80" bgcolor="#0000f f"><span
    onClick="execut eLink(63)">&nbs p;Sub item 6.3</span></td></tr>
    <tr height="1"><td width="1"></td></tr>
    </table>
    </div>
    </body>
    </html>


    Maybe this helps you.

    Nice greetings from
    Thomas


    Comment

    Working...