This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
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
 
Similar Threads
Drag & Drop feature using GWT
how to select an image from a list of images using selenium
drag and drop images on applet from local file system
Struts form bean loading using ajax
How to drag a DIV if there is a image inside?