Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
05-20-2008, 06:42 PM #1
- Join Date
- Jan 2008
- Thanked 0 Times in 0 Posts
Scriptaculous - Saving a positions co-ordinates?
Just wondering this, but say I had a image in scriptaculous and I dragged it around etc. If I pressed save, meaning it would grab the information for the x and y co-ordinates using "document.getElementById('DIVNAME').style.left;" and "document.getElementById('DIVNAME').style.top;" and sent the information to a database, would the getElementById work?
As in, every time I moved the image would it update the style.top and style.left of the image and send it to the database?
If you don't understand I may be able to explain it more, hopefully. :P
05-20-2008, 11:12 PM #2
- Join Date
- Sep 2005
- Thanked 36 Times in 35 Posts
Yes, that would work. The values for 'left' and 'top' won't necessarily be relative to the browser though, so depending on how you're reusing them it could cause problems. If you're going to be setting the values in the same HTML layout it will be fine, but otherwise you might want to use Prototype's getCumulativeOffset instead.
As a tip, if you're using Scriptaculous anyway, then Prototype's $() method is available to you, to save having to type document.getElementById so often.