Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a DOM node from coordinates

Status
Not open for further replies.

ca4928

Programmer
Jan 4, 2005
13
GB
I am trying to let the user move a div from one place to another. When the user clicks on a div, it is removed from its current parentNode and transferred to a temporary moveable div using the DOM. Unfortunately, i don't know how to detect which of the numerous possible locations they have dragged it to in order that i can reconnect it to the fixed document in a new location.

AARgh that was not well explained.

OK. Imagine you are playing a card game on a computer. If you drag a card partially over a pile of cards, the program will detect which pile the card is over, and add the card to that pile, otherwise the card jumps back from whence it came. I am trying to do something similar, the only thing i cant work out is how to detect which 'pile' the 'card' is over.

In IE there is a function that will let you find an element from a coordinate but, unfortunately, it returns the 'card' that is being moved, instead of the pile.
 
This doesn't really answer your question. However, instead of making it a situation where you drag the card to the new location, why not make it play like window's freecell. You click the card to be moved and it will highlight in a different color to indicate that it is being selected. Then, you click on the destination of where you would like the card to be placed. In that case it should be simple enough with the method you described above to detect where the destination is with an onclick handler.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Thanks, nice idea. Kicking myself that i cant claim it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top