Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    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

  2. #2
    Senior Coder
    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.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts