Tuesday, October 27, 2009

Problem with my JavaScript Menu...

I've been trying to solve my JavaScript menu problem with no luck =(. I've tried a few different options but the solutions I have experimented so far are not exactly what I'm after.

Here's what I want to do:
  1. I have a menu listed on the side bar like this:
    • Menu 1
    • Menu 2
    • Menu 3
  2. Menu 2 has a child menu like this:
    • Menu 1
    • Menu 2
      • Sub-menu 2.1
      • Sub-menu 2.2
      • Sub-menu 2.3
    • Menu 3
  3. I want the menu on the home page to be like no [1], but when the user click on Menu 2, it goes to page 2 and the sub-menu is opened automatically like on no [2]. If the parent doesn't have a child menu then it won't opened. 
The easier way to do this to put different navigation menu on each page. However, I'm using the PHP include function for my menu as I mentioned in the previous post and I would like to keep it that way.

A friend suggested that I should give an 'id" for each page and tell JavaScript to behave a certain way when go to the particular page. I'm going to try to do this next.
If anyone has other suggestions, please let me know.

Thank you in advanced.

2 comments:

  1. This one i suggest you use pure CSS DROPDOWN MENU. Personally speaking, I don't like to use JavaScript for dropdown menu. It often create cross browser problems.
    I have uploaded a sample to my web host. see if it helps.
    http://uts2009dmt.net16.net/cssmenu/cssdropdownmenu.html

    ReplyDelete
  2. Thanks for the suggestion Kaida! I spoke to Alastair last week and he suggested that I use the PHP command to tell the menu to show or not and it works! However, I'll keep the CSS drop-down menu in mind for next time.

    Thanks again
    Cheers
    Vera

    ReplyDelete