Forum Moderators: coopster

Message Too Old, No Replies

creating an Image mouseover with php, without using css

creating an Image mouseover with php, without using css

         

aldig

3:41 pm on Jul 18, 2007 (gmt 0)

10+ Year Member



Hello

Any knowledgeable gurus have any idea how to adjust the code below to allow for php to call two different images for mouse off and on events without using css? the first images is m1.jpg.

Code:

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_TEMPLATES . TEMPLATE_NAME.'/images/navigation/'.$language.'/m1.jpg' , 'home') . '</a>

thanks!
Alex

whoisgregg

4:05 pm on Jul 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], aldig!

Because the mouseover event is client side only, PHP can't really be of too much assistance. You'll need to either have a CSS or Javascript (or some combination) approach to providing this functionality.

That said, PHP can certainly be used to dynamically write out that code.

 $image_on = 'some_image_on.jpg';
$image_off = 'some_other_image_off.jpg';
echo '<img src="/images/'.$image_on.'" onmouseover="this.src=\''.$image_off.'\';" onmouseout="this.src=\''.$image_on.'\';"/>';

(My apologies, I have an aversion to OSCommerce code so did not work directly on the tep_ functions you provided. I'm sure it's possible to adapt this code into your application.)