SitePoint Sponsor

User Tag List

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

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

    Hi,

    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.

    http://gurn.net/dresstommy/dresstommy.html

    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
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    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

    z.style.pixelLeft probably translates to:
    document.all[divID].style.pixelLeft

    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] = z.style.pixelLeft;
    Yfield[i] = z.style.pixelRight;
    divID[i] = whatever the div id is;
    }

    you can then send your data like this:

    action = "somepage.xxx?array1=" + Xfield + "array2=" + Yfield + "array3=" + divID

    and on the receiving page, use opener.location.search to get the data.

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


Bookmarks

Posting Permissions

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