Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML drag and drop

 
james stan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compare the dropped elements position relative to the canvas and check if it would fit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic