derekshull Posted May 1, 2013 Share Posted May 1, 2013 (edited) There are a lot of solutions out there as to how to save the position of draggable DIVs but I haven't found any that will help with using a While loop in php. I have a database of "needs" and I want to display all the "needs" that match the persons username and status=inprogress. This could be 1 need or 1,000,000 needs depending on if the criteria is met. I want to save the position of the need (DIV) automatically when it's moved. Is this possible? Here the code I currently have that displays the "needs" (divs) <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <style> #set div { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } #set { clear:both; float:left; width: 368px; height: 120px; } p { clear:both; margin:0; padding:1em 0; } </style> <script> $(function() { $( "#set div" ).draggable({ stack: "#set div" }); }); </script> Edited May 1, 2013 by derekshull Quote Link to comment https://forums.phpfreaks.com/topic/277510-jquery-php-save-position-of-draggable-items-using-while-loop/ Share on other sites More sharing options...
derekshull Posted May 1, 2013 Author Share Posted May 1, 2013 I want to put the values in a database to store them if I can. Quote Link to comment https://forums.phpfreaks.com/topic/277510-jquery-php-save-position-of-draggable-items-using-while-loop/#findComment-1427602 Share on other sites More sharing options...
nogray Posted May 2, 2013 Share Posted May 2, 2013 Since you already using jquery, you can use a sortable widget, http://api.jqueryui.com/sortable/ and serialize the list on change. Quote Link to comment https://forums.phpfreaks.com/topic/277510-jquery-php-save-position-of-draggable-items-using-while-loop/#findComment-1427679 Share on other sites More sharing options...
SahilJariwala Posted October 20, 2013 Share Posted October 20, 2013 Here is the complete guide with code to save the position of draggable element.http://frontend.citynamaste.com/2013/10/how-to-save-position-of-the-draggable-div-in-database/You can save and retrieve its position whenever you want. Quote Link to comment https://forums.phpfreaks.com/topic/277510-jquery-php-save-position-of-draggable-items-using-while-loop/#findComment-1454607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.