Bonjour,
je me mets tout juste à javascript et je bute sur un problème...
En fait, j'ai placé 3 photos dans des td et je veux que sur un clic sur une des photos, qu'elles se replacent aléatoirement.
Pour l'instant, j'essaye juste de placer la première photo choisie aléatoirement dans la première td, après j'utiliserai splice je pense et choisirai aléatoirement une des 2 autres photos puis re splice et affichage de la dernière.
Voici ce que j'ai fait et qui ne fonctionne pas :
<head>
<script language="JavaScript">
function mix() {
tbimage=new Array("photo0","photo1","photo2");
var imageAleatoire=Math.round(Math.random()*3);
document.getElementById("image0").rows[0].cells[0].appendChild(document.createElement('a')); document.getElementById("image0").rows[0].cells[0].lastChild.appendChild(document.createElement('img')); document.getElementById("image0").rows[0].cells[0].lastChild.lastChild.style.height="150px"; document.getElementById("image0").rows[0].cells[0].lastChild.lastChild.src='images/'+tbimage[imageAleatoire]+'.jpg';
}
</script>
</head>
<body>
<div align="center" style="">
<table id="ntab" border='no' rules='none'>
<tr id='fg'>
<td id="image0"> <a> <img src="images/d7.jpg" width="150" height="150" onclick='mix()' ></a> </td>
<td id="image1"> <a> <img src="images/d7_02.jpg" width="150" height="150" onclick='mix()' ></a> </td>
<td id="image2"> <a> <img src="images/d7_03.jpg" width="150" height="150" onclick='mix()' ></a> </td>
</tr>
</table>
</div>
</body>
</html>
--------------------------------------------------------
http://www.projer.fr - dev web
http://www.lysdesign.fr - DA print / web - Illustratrice