News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Javascript problem

Started by snakeplissken, July 27, 2007, 12:56:42 AM

Previous topic - Next topic

snakeplissken

onmouseover="dropdownmenu(this, event, \' $x \')

How can I make the above work, I could never figure out how to use php variables in javascript.

Jeff Lewis

How are you generating the  onmouseover? is it in an echo or just plain HTML?

if it's an echo:


echo '<img src="bah.png" onmouseover="dropdownmenu(this, event, \''. $x . ' \')">';


If it's in HTML:


<img src="bah.png" onmouseover="dropdownmenu(this, event, '<?php echo $x; ?>')">


There's obviously various shortcuts and other ways but that should do you fine...need to know the code around it and how it's being printed (like if it's coming from an echo)
Co-Founder of SMF

snakeplissken

#2
Thanks Jeff,

It was actually from an echo.

But it was late, I wasn't thinking :)

karlbenson

Theres nothing I hate more than working with Javascript and having to test it in various browsers only to find it won't work in one because browser x doesnt support it as an object or whatever.

Advertisement: