Here is an example how you can incorporate the drag and drop feature on multiple images. Use this source and edit only the name of the images (you need to use the image name that you have)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> </title>
<style type="text/css">
</style>
<script type="text/javascript" src="dom-drag.js"></script>
<script type="text/javascript">
window.onload = function(){
Drag.init(document.getElementById("example1"));
Drag.init(document.getElementById("example2"));
Drag.init(document.getElementById("example3"));
Drag.init(document.getElementById("example4"));
}
</script>
</head>
<body>
<img id="example1" src="lips_small.gif" style="position: relative" />
<img id="example2" src="logo.gif" style="position: relative" />
<img id="example3" src="pattern.gif" style="position: relative" />
<img id="example4" src="me.gif" style="position: relative" />
</body>
</html>
You need to notice certain things before applying the drag and drop on the elements of the page, in your case the elements is images.
1. You need to specify a unique ID for each images (img) element.
2. You need to specify a style attribute with a value position:relative for each images (img) element.
3. You need to hook all the images to the drag and drop script via Drag.init method. So in the above example I've done it via the onload event of window object. You need to apply on each and every element you want to apply the drag and drop. In my source code I want it on the four image so I've called the mentioned method four times and mentioned each of my four items. There are lots of other mechanisms using which you can accomplish this such as using an array and a looping construct but at the moment don't worry about those things.
3. Now you can load the page in browser and try to drag the elements.
Bookmarks