Hey all I’m currently learning Java script at the moment. At the moment I’m making a picture slide game using the swap function. I’m trying to make it so when I click on a square then onto a square next to it the pictures will swap around…This is what I have done so far I was wondering if any of you guys could help?
Cheers!
<html>
<title>Puzzle Page</title>
<script>
<head>
script language =(javascript )
function swap (newPosition)
{
temp =document. images[0].src;
temp =document. images[0].src=document.images[1].src;
temp =document. images[1].src=temp;
}
</script>
</head>
<body>
<TABLE border=”1″>
<TR>
<TD><img name=fruits src = fruits/fruit_0.gif onclick=swap(0);> </TD>
<TD><img name=fruits src = fruits/fruit_1.gif onclick=swap(1);> </TD>
<TD><img name=fruits src = fruits/fruit_2.gif onclick=swap(2);> </TD>
</TR>
<TR>
<TD><img name=fruits src = fruits/fruit_3.gif onclick=swap(3);> </TD>
<TD><img name=fruits src = fruits/fruit_4.gif onclick=swap(4);> </TD>
<TD><img name=fruits src = fruits/fruit_5.gif onclick=swap(5);></TD>
</TR>
<TR>
<TD><img name=fruits src = fruits/fruit_6.gif onclick=swap(6);> </TD>
<TD><img name=fruits src = fruits/fruit_7.gif onclick=swap(7);> </TD>
<TD><img name=fruits src = fruits/hole.gif height=”130″ width=”160″ onclick=swap(8);> </TD>
</TR>
</TABLE>
</body>
</html>