Jump to content


Photo

Trying to call js from a PHP menu builder function


  • Please log in to reply
3 replies to this topic

#1 kopman

kopman
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 August 2006 - 02:16 PM

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

#2 Eric_Ryk

Eric_Ryk
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 01 August 2006 - 02:23 PM

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.

#3 kopman

kopman
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 August 2006 - 02:41 PM

Thank you for that, makes sense now. :)

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 01 August 2006 - 04:04 PM

However there is no way to obtain a value from a client-side language and use it on the server-side.

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users