I want to create a puzzle with 6 image slices, however i don't understand the script that i want to create. It has to switch positions with the one clicked before and after. Any help would be great thanks.
Printable View
I want to create a puzzle with 6 image slices, however i don't understand the script that i want to create. It has to switch positions with the one clicked before and after. Any help would be great thanks.
What code do you have so far?
<html>
<head>
<title>image swapping</title>
<script>
function remember(mypackage){
pictureclicked=mypackage
}
function swap(){
memory=pictureclicked.src
pictureclicked.src=sw.src
sw.src=memory
}
</script>
</head>
<body>
<table>
<tr>
<td><img id="zero" src="pic1.jpg" onclick="remember(zero)" width="80" height="100"></td>
<td><img id="one" src="pic2.jpg" onclick="remember(one)" width="80" height="100"></td>
<td><img id="two" src="pic3.jpg" onclick="remember(two)" width="80" height="100"></td>
<td><img id="three" src="pic4.jpg" onclick="remember(three)" width="80" height="100"></td>
<td><img id="four" src="pic5.jpg" onclick="remember(four)" width="80" height="100"></td>
<td><img id="five" src="pic6.jpg" onclick="remember(five)" width="80" height="100"></td>
</tr>
<tr>
<td colspan="4" align="center">
swap with<img name="sw"
src="pic1.jpg"
width="50"onclick="swap(swap)"></td>
</tr>
</table>
</body>
</html>
i just want to get rid of this piece of code so it can be able to switch from 2 pics inside the puzzle instead of going back to the "memory" one
<td colspan="4" align="center">
swap with<img name="sw"
src="pic1.jpg"
width="50"onclick="swap(swap)"></td>
i figured it out. but does anyone know how to make a script that counts the number clicks made to arrange the scrambled puzzle?