Results 1 to 2 of 2

Thread: Switching Content using a menu

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switching Content using a menu

    Hi,

    I have 3 tables that are generated using PHP to fetch information from a db.

    Instead of displaying the 3 tables below each other, I would like to display each using a simple menu in a left nav bar that "dynamically" displays the tables in a right content area, when the respective table name is selected from the menu.

    Any ideas on the best way to do this? The tables are quite large, so I would want to prevent querying the db each time... but I guess that is an option.

    Was thinking of using DIV visible, but I'm not sure if it will always display at the top.

    Any ideas greatly appreciated.

    Thanks!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    A dropdown menu could switch divs by hiding one and making another visible, yes. That's a good way.

    Alternatively you could use Ajax, but that would query the database every time.

    I think using the hiding/showing method is a good idea.

    document.getElementById('mydiv').style.display = 'none';
    document.getElementById('mydiv').style.display = 'block';

    Those two lines will invert visibility. Just apply them as a function to show the right div-- hide the others and show the desired one. Make that the onChange for the dropdown.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •