Getting Images Positions After Dragging and Dropping

Javascript coding ..

Moderators: macek, egami, gesf

User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 84
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Getting Images Positions After Dragging and Dropping

Postby JordanMRichards » Tue May 29, 2012 8:37 am

Hey Everyone,

I'm not too good with javascript and jquery myself.

I want to use the jquery UI (draggable and dropable) to make a system where you have images and you drop them onto one MAIN image. Then get the positions of where them images are and feed back that result to a php file, where I could do the rest.

I'm not sure how I'd do this, could someone just tell me HOW I'd do it?

Thank you.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 Year Old Programmer & Graphic Artist, Confident and Courageous
Image

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: Getting Images Positions After Dragging and Dropping

Postby Nullsig » Tue May 29, 2012 10:40 am

Do you need to just figure out how to get the positions? Or do you also need to know how to make dragable and dropable items?

User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 84
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Re: Getting Images Positions After Dragging and Dropping

Postby JordanMRichards » Tue May 29, 2012 1:18 pm

Figure out the positions and how I'd send them to a php file

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: Getting Images Positions After Dragging and Dropping

Postby Nullsig » Wed May 30, 2012 6:50 am

These will give you the x and y offsets of whatever element you ask for. You should use unique "id" to reference each element.

Code: Select all

var x = $("#element").offset().left;
var y = $("#element").offset().top;


To send the information to PHP for storage or manipulation you can either use more JQuery or JavaScript to push the values into hidden fields on a form you are submitting.

Or if you don't want to reload the page you can have some sort of trigger that calls a PHP script using AJAX and send that script these variables.


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 0 guests