Coordinates of a draggable object

Newbie Member
7Dec2009,17:55   #1
rwwilcox's Avatar
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
Go4Expert Founder
7Dec2009,18:17   #2
shabbir's Avatar
All you are trying to do is store some numbers in a file and what makes you think it cannot be done.
Newbie Member
7Dec2009,21:34   #3
rwwilcox's Avatar
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
Ambitious contributor
8Dec2009,00:03   #4
venami's Avatar
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;
Newbie Member
9Dec2009,22:37   #5
tommyp's Avatar
This is quite usefull, how would one submit this into a form textarea when the form is submitted?
Ambitious contributor
9Dec2009,23:01   #6
venami's Avatar
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.