Page 1 sur 1

Javascript dans php

Posté : 16 janv. 2007, 14:14
par No_life
Bonjour à tous,

J ais à la base un bouton fonctionnant avec rollover et rollout en javascript.

Code : Tout sélectionner

<a onmouseover="more('tooltip1', event);" onmouseout="less('tooltip1');"><img src="images/horsstock.gif" style="margin-right:15px;"></img></a>
Lorsque je veux l'inserer dans un echo sa ne fonctionne pas:
<?php
if ($product_info['products_quantity'] == 0 ){

echo '<a  onmouseover="more('tooltip1', event);" onmouseout="less('tooltip1');"><img src="images/horsstock.gif" style="margin-right:15px;"></img></a>';
}
?>
Le probleme vient des '' pour 'tooltip1'

comment les faire accepter ?

Merci d 'avance.

Posté : 16 janv. 2007, 14:27
par Gsgsd
C'est si tu commence un echo avec un ' alors tout les ' qui ne sont pas en relation avec le code php doivent etre precedé d'un "\" donc ton code serait:
<?php
if ($product_info['products_quantity'] == 0 ){

echo '<a  onmouseover="more(\'tooltip1\', event);" onmouseout="less(\'tooltip1\');"><img src="images/horsstock.gif" style="margin-right:15px;"></img></a>';
}
?>