469,641 Members | 1,164 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

(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:

http://img520.imageshack.us/img520/4465/layoutic8.gif

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.
Oct 15 '07 #1
5 1656
acoder
16,027 Expert Mod 8TB
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.
Oct 15 '07 #2
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.
Oct 15 '07 #3
acoder
16,027 Expert Mod 8TB
What do you mean when you say you can't use Ajax? If you can use PHP, you should be able to use Ajax.
Oct 15 '07 #4
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?
Oct 15 '07 #5
acoder
16,027 Expert Mod 8TB
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.
Oct 15 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.