Page 1 of 1

Problem with simple PHP include and javascript menu

Posted: Sun Jan 16, 2005 10:56 am
by graydog
I'm having a problem with a simple include file that contains a dropdown menu. The dropdown menu contains javascript.

I'm having the same problem running it both locally on my WAMP server and when I post it to the web.

When I go to the menu.php page it works fine, but when I access the page that contains the include file "index.php" the menu is not working. You can see the list items on the menu, but the javascript or css don't seem to be working. I've tried referencing the .js files and the .css files with absolute and with relative paths. Neither seems to work.

Here's how I'm calling the page menu.php

Code: Select all

include ("menu/menu.php");
Here's a URL to the menu file: http://www.charlierichjr.com/orban/2TEST/menu/menu.php

and here's one to the page that is calling it.
http://www.charlierichjr.com/orban/2TEST/

Any help would be greatly appreciated.

Posted: Sun Jan 16, 2005 11:20 am
by JAM
JAM wrote:First thought:

Code: Select all

<LINK REL="stylesheet" TYPE="text/css" HREF="css/base.css">
Bad path...

The above means the css should reside in:

Code: Select all

http://www.charlierichjr.com/orban/2TEST/css/base.css
...and apparently it does not
The requested URL /orban/2TEST/css/base.css was not found on this server.
Perhaps it should be

Code: Select all

<LINK REL="stylesheet" TYPE="text/css" HREF="../css/base.css">
or similiar instead. Play with it abit.
That would make it down one folder (to /orban/) then /css/base.css. At least there's were I found it.

Posted: Sun Jan 16, 2005 12:36 pm
by graydog
Thanks,

You got me headed in the right direction. I was actually not concerned so much with the "base.css" stylesheet, but that made me think. Why not put the menu.css in the base.css stylesheet and just reference the whole thing that way. So, that worked fine, and yes, I had the wrong pathway to the file. That's fixed now.

I added the php include to my header.php file. Now it will be referenced across the entire site.

I also had to put the javascript to the menu.js file in the actual index page that I'm calling the function from. That was another biggie.

At least I can see the menu now. The only problem is that it takes "forever" to load.

Thanks for getting me a bit closer to making this thing work.

Posted: Sun Jan 16, 2005 3:15 pm
by JAM
Glad I atleast gave you a push into the right direction. I also noticed the time it took to load the page. It's much better now, but not nearly as fast as the root-host charlierichjr.com. (Just adding this so you don't think it's something on your end only...)

You should add "time()-checks" on various of places in your code to see what fubars it...