Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1
    Join Date
    Mar 2007
    Posts
    106
    Tokens
    0

    Default Drag drop, save position

    Hey, does anyone know how i can make it so i can drag an object then i can press save and it will save the x and y cordinates to mysql?

  2. #2
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    Post an example of the JavaScript app. you're using.
    kinda quit.

  3. #3
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    I don't want to make a new thread on this.

    Im using Scriptaculous (think thats how you spell it)

    I can't make it drag, I can do sortables, etc. But how can I limit the drag in a specific table/div.

    Also how can I export the x,y of the div?

  4. #4
    Join Date
    Mar 2007
    Posts
    106
    Tokens
    0

    Default

    this is what i have so far

    PHP Code:
    <style>
    <!--
    .dragme{position:relative;}
    -->
    </style>
    <script language="JavaScript1.2">
    <!--
    var ie=document.all;
    var nn6=document.getElementById&&!document.all;
    var isdrag=false;
    var x,y;
    var dobj;
    function movemouse(e)
    {
      if (isdrag)
      {
        dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
        dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
        return false;
      }
    }
    function selectmouse(e) 
    {
      var fobj       = nn6 ? e.target : event.srcElement;
      var topelement = nn6 ? "HTML" : "BODY";
      while (fobj.tagName != topelement && fobj.className != "dragme")
      {
        fobj = nn6 ? fobj.parentNode : fobj.parentElement;
      }
      if (fobj.className=="dragme")
      {
        isdrag = true;
        dobj = fobj;
        tx = parseInt(dobj.style.left+0);
        ty = parseInt(dobj.style.top+0);
        x = nn6 ? e.clientX : event.clientX;
        y = nn6 ? e.clientY : event.clientY;
        document.onmousemove=movemouse;
        return false;
      }
    }
    document.onmousedown=selectmouse;
    document.onmouseup=new Function("isdrag=false");
    //-->
    </script>
    <?
    ob_start
    (); //Allows Cookies
    include("config.php"); //Connects to Database
    ?>
    <?
    if($logged[username]){
    $sql="SELECT * FROM uses_furni WHERE username = '$logged[username]' ORDER BY `id`";  
    $result=mysql_query($sql);  //Selects the items from the database
    while($rows=mysql_fetch_array($result)){ //Puts the info in an array
    echo("<div style=\"position: absolute; width: 28px; height: 30px; z-index: 1; left:$rows[ypos] px; top:$rows[xpos] px;\" id=\"$rows[id]\">
    <p><img src=\"
    $rows[itemimage]\" class=\"dragme\"></div>");
    $query mysql_query("Update `uses_furni` Set `xpos` = '$x', `ypos` = '$y' Where `id` = '$image'") or die(mysql_error());
    }
    }
    ?>

    id like to make it so theres a save button and it saves the x and y cordinates to that item.

  5. #5
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    That code was on TT.

  6. #6
    ScottDiamond Guest

    Default

    Quote Originally Posted by PixelWill View Post
    That code was on TT.
    Your point?

    And I'll leave this in the hands of nets, he's a coding legend.

  7. #7
    Join Date
    Apr 2007
    Posts
    50
    Tokens
    0

    Default

    I've got it:

    http://www.dynamicdrive.com/dynamicindex4/image3.htm


    Its the script were u drag Images Or DIV Boxs ! Enjoy!

    Soon To Be Released....

  8. #8
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    No point "Scott" :rolleyes:

    Better than saying something newby like "point" I suppose.

  9. #9
    Topps Guest

    Default

    phpme, that is just drag and drop and not saved so you can't come back to it how you left it. I would like this aswell, one of the best scripts people could have.

  10. #10
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    Does it have to be saved permanently, or could it be saved in a cookie (positions would be lost once the user clears their cookies)? It would be easier and more efficient to use cookies, if that's a viable option.
    kinda quit.

Page 1 of 3 123 LastLast

Posting Permissions

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