Vertical Menu

Discussion in 'JavaScript' started by Jeca, Jan 17, 2007.

  1. #1
    Hi everybody,

    I’m trying to make a vertical menu that would expand. This is javascript function that I have so far:

    menu_status = new Array();
    function showHide(theid)
    {
    if (document.getElementById)
    {
    var switch_id = document.getElementById(theid);

    if(menu_status[theid] != 'show')
    {
    switch_id.className = 'show';
    menu_status[theid] = 'show';
    }
    else
    {
    switch_id.className = 'hide';
    menu_status[theid] = 'hide';
    }
    }

    It works fine except one thing: once I select different parent-menu a child-menu from previous parent-menu is not closed. So I could expend every parent-menu and see all child-menus in same time. What I want is to see child-menu from only selected parent-menu, and I don’t know how to do it!

    Any ideas?

    Thanks so much for your time guys

    Jeca :D
     
    Jeca, Jan 17, 2007 IP