Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Getting Images Positions After Dragging and Dropping

Javascript coding ..

Moderators: macek, egami, gesf

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
JordanMRichards
New php-forum User
New php-forum User
 
Posts: 84
Joined: Mon Apr 23, 2012 7:43 am

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
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 JordanMRichards » Tue May 29, 2012 1:18 pm

Figure out the positions and how I'd send them to a php file
User avatar
JordanMRichards
New php-forum User
New php-forum User
 
Posts: 84
Joined: Mon Apr 23, 2012 7:43 am

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.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.