SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Northampton, UK
    0 Post(s)
    0 Thread(s)

    Passing X,Y positions of draggable layers to INPUT boxes?


    I have a page where you can dress someone up in silly clothes using a skeleton image, and several items of clothing as gifs in dragable layers.

    How can I use a bit of j'script to grab the X and Y values of each layer and then put them in to a load of hidden form fields?

    I then intend on having the user click the submit button when they've put all the stupid clothes in the wrong places... and saving the results in a database. I can work this bit out myself, but wonder if anyone could help me with the javascript? Thanks!

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    where the World once stood
    0 Post(s)
    0 Thread(s)
    Hi Meza,

    I only took a quick peek at the code, but you would probably want to put the code in your move() function since that seems to be the last function called.

    pixelLeft is the x-axis; pixelTop is the y-axis probably translates to:

    since you have more than one layer, you will need to have an array or a mess of fields. If you decide upon an array, something like this might work:
    for (i = 0; i < numOfLayers; i++)
    Xfield[i] =;
    Yfield[i] =;
    divID[i] = whatever the div id is;

    you can then send your data like this:

    action = "" + Xfield + "array2=" + Yfield + "array3=" + divID

    and on the receiving page, use to get the data.

    Where the World Once Stood
    the blades of grass
    cut me still


Posting Permissions

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