aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes HTML drag and drop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML drag and drop" Watch "HTML drag and drop" New topic
Author

HTML drag and drop

james stan
Greenhorn

Joined: Oct 13, 2012
Posts: 25
Hi ,
I am creating an HTML page . The page has 2 divs
a)one is a sidebar which has images in it.
b) the second div is canvas onto which images from the div1 will be dragged and dropped.

Now in the canvas , i have a grid as background(sort of like graph paper with each square of like 25px ). The images will be have to be dragged onto canvas in the exact squares(on graph paper like 3 from top border,2 from right ) . If users drops images onto exact squares ,nothing happens . But if image is dropped onto wrong square a JS alert should pop up.

Now i have been able to drag and drop images from div 1 to div 2 but i need to know how i can check if image from div1 is dropped onto right square in canvas?
TIA
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Compare the dropped elements position relative to the canvas and check if it would fit.
 
Consider Paul's rocket mass heater.
 
subject: HTML drag and drop