[PHP-JS] Intégrer un code javascript dans du php
Bonjour,
Voilà j'ai ce code qui me permert de créer une galerie photos
Dans <head>
Code:
1 2 3 4 5 6 7 8
| <script language="JavaScript">
function LoadGallery(pictureName,imageFile,titleCaption,captionText)
{
document.getElementById(pictureName).src = imageFile;
document.getElementById(titleCaption).innerHTML=captionText;
}
</script>
</head> |
Dans <body>
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
<table border="0" cellpadding="2">
<tr>
<td><img style="border: 1px black solid" alt="Photo gallery" src="img/logo.gif" id="Gallery2" width="201" height="201"><br>
<div id="Caption2">text captation<div></div></div>
<td>
<ol>
<li><a href="#_self" onclick="LoadGallery('Gallery2','img/logo.gif','GalleryCaption2','text captation')"><img src="img/logo.gif" width="50" height="50"></a></li>
<li><a href="#_self" onclick="LoadGallery('Gallery2','img/img2.jpg','GalleryCaption2','text cap 2')"><img src="img/img2.jpg" width="50" height="50"></a></li>
<li><a href="#_self" onclick="LoadGallery('Gallery2','img/logo3.gif','GalleryCaption2','text 3')"><img src="img/logo3.gif" width="50" height="50"></a></li>
</ol>
</td>
</tr>
</table> |
Ca fonctionne très bien par contre quand j'essaie de l'insérer dans du PHP ça ne marche plus. J'ai laissé le même code dans <head> et dans <body> j'ai ce code là:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
echo "<table>"."\n";
echo "<tr>"."\n";
echo "<td>";
echo "<img style=\"border: 1px black solid\" alt=\"Photo gallery\" src=\"img/logo.gif\" id=\"Gallery2\" width=\"201\" height=\"201\"></td>\n";
echo "<div id="Caption2">text captation<div></div></div>\n";
echo "<td>\n";
echo "<ol>\n";
echo "<li><a href=\"#_self\" onclick=\"LoadGallery(\"Gallery2\",\"img/photo1.gif\")\">Text 1</a></li>\n";
echo "<li><a href=\"#_self\" onclick=\"LoadGallery(\"Gallery2\",\"img/photo2.gif\")\">Text 2</a></li>\n";
echo "<li><a href=\"#_self\" onclick=\"LoadGallery(\"Gallery2\",\"img/photo3.gif\")\">Text 3</a></li>\n";
echo "</ol>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n"; |
Merci d'avance pour votre aide