Javascript dans php

No_life
Invité n'ayant pas de compte PHPfrance

16 janv. 2007, 14:14

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.

Eléphanteau du PHP | 36 Messages

16 janv. 2007, 14:27

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>';
}
?>