need to use php within the menu files

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Darkangel
Advanced
Advanced
Posts: 24
Joined: Sat Mar 05, 2005 12:44 am

need to use php within the menu files

Post by Darkangel »

Hi to all the team,

I've implemented the menu system which works perfectly but now i need to change the link of the image as they could come from two different sources!!

for the rest of my website i simply need instead of the image name to put
<? echo img_01; ?> for instance..

However my probleme is that here the name of those images are within a javascript file!
how can I make this echo works within the js file.

i thought of inserting the whole menu system in a php file, it still works but i don't know how to insert php withint javascript code...

thanks for helping me..
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Re: need to use php within the menu files

Post by kevin3442 »

Hi Darkangel,
Darkangel wrote:i thought of inserting the whole menu system in a php file, it still works but i don't know how to insert php withint javascript code...
You are exactly on the right path. All you have to do is rename menu_data.js to menu_data.php and load the script into your page accordingly:

Code: Select all

<script type="text/javascript" src="menu_data.php"></script>
Since you're loading the file in a javascript <script> block, the browser will see it as javascript code. And because the filename extension is .php, the code is run through the php parser on the server, and the result is delivered to the browser (the output in this case should be valid javascript code).

Cheers,

Kevin
Post Reply