Coordinates of a draggable object

rwwilcox's Avatar, Join Date: Dec 2009
Newbie Member
Does anyone know how to store the coordinates of a draggable image in a .txt file, to allow the same image to be re-loaded in the same position on another page?

Hope someone can help,
Thanks
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
All you are trying to do is store some numbers in a file and what makes you think it cannot be done.
0
rwwilcox's Avatar, Join Date: Dec 2009
Newbie Member
I know it can be done, and i know that i need to use GetElementById, e.clientX, and e.ClientY. But im new to this and just wanted some advice of how to go about it.

Thanks
0
venami's Avatar, Join Date: Dec 2008
Ambitious contributor
But the clientx and clienty gives the current mouse position and not the image's position on a screen.
You can do as follows:

Code:
var x = document.images.imagename.offsetLeft;
var y = document.images.imagename.offsetTop;
0
tommyp's Avatar, Join Date: Dec 2009
Newbie Member
This is quite usefull, how would one submit this into a form textarea when the form is submitted?
0
venami's Avatar, Join Date: Dec 2008
Ambitious contributor
Create a javascript which takes the above two values as arguments. Inside the function, use:
Code:
// here 'txtarea' inside brackets is the ID set for the textarea tag
txtarea = document.getElementbyId('txtarea');
txtarea.value = x + " " + y;
Then in the onlcick event of the submit button, call this function.