PDA

View Full Version : Dom Drag and Drop error



bonesbrigade
11-14-2008, 03:03 AM
1) Script Title: DOM Drag & Drop Script

2) Script URL (on DD): DOM drag and drop (http://www.dynamicdrive.com/dynamicindex11/domdrag/index.htm)

3) Describe problem: I can't seem to get the drag end coordinates to work in a simple if statement. Do I have bad syntax or something? Here is my code:


var fdThumb = document.getElementById("fd");
Drag.init(fdThumb, null, 0, 720, 0, 315);
fdThumb.onDragEnd = function(x, y)
if(x <= 720 && x >= 670 && y <= 160 && y >= 30){
alert('x: ' + x + ' y: ' + y);//just to see if it works
}

When I just have the code without the if statement:

var fdThumb = document.getElementById("fd");
Drag.init(fdThumb, null, 0, 720, 0, 315);
fdThumb.onDragEnd = function(x, y)
alert('x: ' + x + ' y: ' + y);//just to see if it works

it works fine, so I am thinking maybe I have a syntax error or something.

ddadmin
11-14-2008, 06:59 AM
There may be other errors from code you haven't posted, but just based on it, the code in red is missing:


var fdThumb = document.getElementById("fd");
Drag.init(fdThumb, null, 0, 720, 0, 315);
fdThumb.onDragEnd = function(x, y){
if(x <= 720 && x >= 670 && y <= 160 && y >= 30){
alert('x: ' + x + ' y: ' + y);//just to see if it works
}
}