Jump to content

Archived

This topic is now archived and is closed to further replies.

kopman

Trying to call js from a PHP menu builder function

Recommended Posts

I have inherited a website that has 40 pages each with the code for the menu in it. I want to remove that to it's own function in a separate file to make management easier. I have created the file and added the function which builds a $menu variable which is returned to the main file. The function adds line similar to below

$menu .= "<img border='0' id='img70' src='images/nav_buttons/home_link.gif' height='20' width='156' alt='Home' onmouseover='FP_swapImg(1,0,/*id*/'img70',/*url*/'images/nav_buttons/home_active.gif')' onmouseout='FP_swapImg(0,0,/*id*/'img70',/*url*/'images/nav_buttons/home_link.gif')' onmousedown='FP_swapImg(1,0,/*id*/'img70',/*url*/'images/nav_buttons/home_hover.gif')' onmouseup='FP_swapImg(0,0,/*id*/'img70',/*url*/'images/nav_buttons/home_link.gif')' fp-style='fp-btn: Glass Capsule 1; fp-font-color-normal: #D82D01; fp-font-color-hover: #D82D01; fp-font-color-press: #D82D01; fp-justify-horiz: 0; fp-proportional: 0' fp-title='Home'></a></TD></tr>";

As you can see it includes calls to a javascript function to replace images when the cursor moves in and out of the menu button and the picture should change as you do it. These calls aren't working. Should I be approaching this differently or are the js functions not going to work when called in this way?

Thanks.
Peter

Share this post


Link to post
Share on other sites
What you have is a case of client-side vs. server-side. Server-side is not seen by the browser, while client-side is. So javascript is client-side, and will be sent through to the browser and read. So in this case, that will work. However there is no way to obtain a value from a client-side language and use it on the server-side.

Share this post


Link to post
Share on other sites
[quote]However there is no way to obtain a value from a client-side language and use it on the server-side.[/quote]
As was said in the movie Independence Day "That is not entirely accurate".

You can now pass information from the client to the server without invoking a page load by using AJAX.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.