(Javascript) calling user requested div content to another div?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Phantom
    New Member
    • Oct 2007
    • 4

    (Javascript) calling user requested div content to another div?

    I am re-designing a website which currently makes use of Frames. (I want to replace them with something more convenient.)

    It has a layout page, a menus frame and content frame for various content pages (also a links frame.)

    What I want to do is make the site completely dynamic. As in, I want to keep the layout, content, menu and links areas in separate files so that updating is easy. Or at least separate the layout from the content so that changing it only needs to be done on one page

    Here is an image to make the layout clearer:



    I looked into using PHP, made an index page and menus.php include page and put divs instead of Frames, but it all started to look too uncessecarily complicated using an IF/Case statment with the GET variable function.

    Plus, it requires a page refresh before any content is even loaded...

    The problem was with using includes, I would need to repeat the layout code with the content.

    I require a situation that when the user clicks a menu in the menus div the content would be produced for the right page in the content div. (Almost like an Ajax application yet possibly with a page refresh.) The menus area could even be on the same page as the layout.

    I read in a search that Javascript was a better way to achieve this. I can't really use Ajax though, the host does not support it.

    I am really surprised that I cannot not find a more benifitial way to do this without Frames...

    If anyone can suggest how I can achieve this it would be gladly appreciated.

    I hope if anyone can provide an answer, this will come up in a search if people are looking for similar things too.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Do you need to get the content of the content div from the server? If not, you could have all the divs on the page, but hidden except the default one. When a link is clicked, the current one is hidden and the div corresponding to the link is shown.

    You can use style.display set to 'block' and 'none' to show and hide.

    Comment

    • Phantom
      New Member
      • Oct 2007
      • 4

      #3
      Thank you for the welcome.


      This seems like it could work, but I think that suggests the user would have to load all the site content on the first page...

      Maybe it would be better if I asked the same question for a PHP solution again.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        What do you mean when you say you can't use Ajax? If you can use PHP, you should be able to use Ajax.

        Comment

        • Phantom
          New Member
          • Oct 2007
          • 4

          #5
          I thought I needed ASP support, for some reason.

          Nevermind, in this case would it be easier to do in Ajax and are there any tutorials I could follow that would allow me to set up this calling system from menu to content?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            See this example - the example server-side language is ASP, but it can easily be replaced with PHP.

            Also check out the Ajax tutorial links in Offsite Links.

            Comment

            Working...