Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool Action On MouseUp (Drag And Drop)

    Okay I Don't Know Much About Javascript, But I Need A Hand
    I Have A Drag And Drop Script Along With A Simple Script To Make Things Appear And Disappear Bt Using This Line: ShowHide('Table'); return false;
    I Want to Make It So That When I Drag Something over a Div, More Preferably a Table or an Image and Then Let Go of Your Mouse (onMouseUp) It Makes the Object Disappear Or Have An Action Happen

    Thanx
    ________________________________________________________________________________________

    Alright, I wrote this a while ago and This Time I'll Be More Clear And Simple.
    I Want To Make It So That If A Div Hovers Over A Table By Drag And Drop And You Drop Your Div in The Table An Action happens
    Last edited by Clayf700; 06-19-2010 at 04:41 AM.

  • #2
    New Coder
    Join Date
    Feb 2010
    Posts
    44
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Well, in the onMouseUp event you're going to have to figure out if the mouse coordinates are within the boundaries of an element that you care about...

    So if you have only one object, say a trash can, then just get the mouse coords and the left, top, width, height values of the trash can and determine if the mouse was inside that (at the time of the onMouseUp event).

    If you have multiple elements that you can drop objects onto: Make an array of all the objects. In onMouseUp you get the mouse coords and then loop through your array of all objects, getting the left, top, width, height of each one and detecting if the mouse is inside one of them... then depending on which element it is you can perform the action associated with dropping it on that element (probably store that as your own function on each element).

    Hopefully that makes some sense... though it might not if you aren't familiar with javascript.

    This problem isn't exactly trivial unless you have programming experience and a bit of experience with Javascript.

    Good luck.

  • Users who have thanked Skychan for this post:

    Clayf700 (06-19-2010)

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    For The Most Part I Can Insert It in An HTML, Pretty Sad Considering How I'm In A Javascript Fourm.
    So Here Is My sad sad Attempt,

    Code:
    //The coordinates Code
    onMouseUp="function(){ShowHide('Table');return false;"}
    how was it?
    anyways could you give me the code for the coordinates?

    P.S. ah yes! Sooo Useful Thanx Man! Pretty much A Trash Can Was What I Was Aiming For, Thanx
    Last edited by Clayf700; 06-19-2010 at 05:15 AM.

  • #4
    New Coder
    Join Date
    Feb 2010
    Posts
    44
    Thanks
    0
    Thanked 3 Times in 3 Posts
    PM me tomorrow and I might have time to give you a bit of code... but honestly I'm not going to build the whole thing for you. Start learning about the DOM and how to get values like offsetwidth/height absoluteleft/top. At that point you'll probably be able to write the code yourself. Well probly not, but you might be able to work with the bit of code I'll give you tomorrow.

    gnite

  • #5
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    got it


  •  

    Posting Permissions

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