wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML drag and drop" Watch "HTML drag and drop" New topic

HTML drag and drop

james stan

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?
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
Compare the dropped elements position relative to the canvas and check if it would fit.
wood burning stoves
subject: HTML drag and drop
Similar Threads
drag and drop images on applet from local file system
Struts form bean loading using ajax
how to select an image from a list of images using selenium
How to drag a DIV if there is a image inside?
Drag & Drop feature using GWT