View Full Version : Getting cords
wsg14
27-10-2008, 07:47 PM
I'm using script.aculo.us draggables, and how would I go about finding the cords for a dragged box. I've searched and found two threads about this topic but they don't work/I don't understand them.
If you know how to find the cords, please post. +rep
Dentafrice
27-10-2008, 09:38 PM
var x;
var y;
var element;
element = $('elementName');
x = element.offsetLeft;
y = element.offsetTop;
I think?
wsg14
27-10-2008, 10:01 PM
The can I just save the cords using a cookie?
wsg14
29-10-2008, 07:56 PM
bumppp
Edited by Yoshimitsui (Super Moderator): Please do not multiple post.
Dentafrice
29-10-2008, 08:01 PM
Why would you want to save them in a cookie for?
What are you trying to do? :s
wsg14
29-10-2008, 09:03 PM
I want it so a user can go on this page, drag boxes where they want to, then save it. (this'll be their profile page)
I want it so a user can go on this page, drag boxes where they want to, then save it. (this'll be their profile page)
Then they'll empy their cookies and it'll all be gone?
Dentafrice
29-10-2008, 09:25 PM
I want it so a user can go on this page, drag boxes where they want to, then save it. (this'll be their profile page)
Well save it in MySQL.. because when a user clears his cookies.. everything saved will be gone..
wsg14
29-10-2008, 10:05 PM
Mkay;
I still don't know how to physically view the cords though (I know how to find them)
Robbie
29-10-2008, 10:12 PM
document.write(x)
document.write(y)
Presuming you have set the variables like shown above.
wsg14
29-10-2008, 10:17 PM
I just have the code Caleb gave me.
Robbie
29-10-2008, 10:20 PM
Then echo the variables by using document.write as shown.
var x;
var y;
var element;
element = $('elementName');
x = element.offsetLeft;
y = element.offsetTop;
document.write(x);
document.write(y);
Dentafrice
29-10-2008, 10:23 PM
The variables are stored in x and y.. that's how you access them..
wsg14
29-10-2008, 10:39 PM
Alright, thanks. How would I turn them into a PHP variable?
Dentafrice
29-10-2008, 10:42 PM
You've got to get them to PHP first.. which would be an AJAX Request.. and since you're using Prototype, just use Ajax.Request.
Robbie
29-10-2008, 10:45 PM
Could do something like this (messy but yeah)
document.write("<a href='save.php?x=" + x + "&y=" + y + "'>Save your co-ords!</a>");
wsg14
29-10-2008, 11:07 PM
Thanks Robbie and Caleb, I know what to do now.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.