Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Getting cords

  1. #11
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    I just have the code Caleb gave me.

  2. #12
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    1,290

    Latest Awards:

    Default

    Then echo the variables by using document.write as shown.

    Code:
    var x;
    var y;
    var element;
    
    element = $('elementName');
    
    x = element.offsetLeft;
    y = element.offsetTop;
    
    document.write(x);
    document.write(y);

  3. #13
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    The variables are stored in x and y.. that's how you access them..

  4. #14
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Alright, thanks. How would I turn them into a PHP variable?

  5. #15
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    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.

  6. #16
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    1,290

    Latest Awards:

    Default

    Could do something like this (messy but yeah)

    Code:
    document.write("<a href='save.php?x=" + x + "&y=" + y + "'>Save your co-ords!</a>");
    Last edited by Robbie; 29-10-2008 at 10:48 PM.

  7. #17
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Thanks Robbie and Caleb, I know what to do now.

Page 2 of 2 FirstFirst 12

Posting Permissions

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