Jump to content

Trying to call js from a PHP menu builder function


kopman

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
Link to comment
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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.