View Full Version : DRag and drop


AngeLofPeAcE
04-01-2003, 08:13 PM
hi... i used the drag and drop code from some site and it worked but some of the lings i want to go on top of each other...just go under it. if you know what i mean. here is the code im using.


first this in one place:

<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
<!--

/*
Drag and Drop Script-
? Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

var dragapproved=false
var z,x,y
function move(){
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}
}
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}
}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
//-->
</script>


THEN THIS IN ANOTHER

<html>
<head>
<!--drag engine code installed here-->
</head>
<body>
<img src="GREENPOSTERBACK.gif" class="drag"><br>
</body>
</html>


AND THIS NEXT TO IT

<html>
<head>
<!--drag engine code installed here-->
</head>
<body>
<img src="pencil.gif" class="drag"><br>
</body>
</html>




SO WHEN I WANT THE PENCIL IMAGE TO GO OVER THE POSTERBACK IMAGE....IT GOES UNDER IT. HOW DO I FIX THAT??? PLEASE HELP. THANKS

TheDisturbedOne
04-03-2003, 01:13 AM
could you please give me the link that you used to get the code?

AngeLofPeAcE
04-03-2003, 02:57 AM
how is that gonna help me?? :) well if your just doin this for yourself the link is dynamicdrive.com If your helpin me the link is dynamicdrive.com lol well please please help me!!! thanks

TheDisturbedOne
04-03-2003, 08:19 PM
do you put this is in the head section of your webpage? <style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
<!--

TheDisturbedOne
04-03-2003, 08:21 PM
you need need to post this in your head section of your web page <style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
<!--
so when is done it will look like this:

<html>
<head>
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
</head>
<body>