Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 200339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:06:11+00:00 2026-05-11T17:06:11+00:00

I am wondering the "how it works" and "how it should be designed and

  • 0

I am wondering the "how it works" and "how it should be designed and implemented" side of the basic drag & drop functionality.

I have never yet implemented such functionality. I am planning to do so for one of my projects and I do have some ideas on how to implement it. I wanted to make sure I am on the right path and that you people most probably have something to say about the matter too…

Let’s imagine I have 5 elements listed as following and grabbed from a database;

<div id="1">this is content for 1</div>
<div id="2">this is content for 2</div>
<div id="3">this is content for 3</div>
<div id="4">this is content for 4</div>
<div id="5">this is content for 5</div>

since this is pulled off from a database we know that it has a field called "sequence" or "order" to distinguish the order we are going to output. Let’s also imagine currently the "sequence" column values are the same as the IDs of the divs. so: 1, 2, 3, 4 and 5 respectively.

My question and thoughts;

If I drag div 4 and drop it between 1 and 2; what are the steps from there on? E.g:

  1. determine the id of the div that is being dragged (let’s call this div-a)

  2. determine the id of the div that div-a is being inserted after (or before) in this case after and therefore after div id 1 (let’s call this div-b)

  3. Update div-a‘s sequence in DB and set it to the current sequence of div-b

After this step, I am all confused… Do I count all the divs and according to whichever order the divs are, do I update the DB accordingly? Or am I completely wrong and is there another way?


thanks for the answers but I know there are plugins and other stuff to get this done but I am only interested in the logic part of it.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:06:11+00:00Added an answer on May 11, 2026 at 5:06 pm

    I believe jquery gives you a way to grab their order based on id?

    The way I’ve been doing it is every time an action occurs, grab the current order, send it back to my app via ajax. Then my app just parses out the ids from what it was given and updates every item’s order value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if it's possible to "rebuild" relationships in Core Data. Basically, I messed
Wondering if someone could help me. I have next to no knowledge with Ajax,
So, I have this source: #include <winsock2.h> #include <windows.h> #include <iostream> #pragma comment(lib,"ws2_32.lib") using
I am wondering what would be a pythonic solution for this question. In "aa67bc54c9",
I'm currently working on a project at work using the HTML5 Drag and Drop
this is probably really simple for a jQuery expert. I have <div id="form23"><form><textarea>blahblah</textarea><input type="button"
Today I visited jsPerf and now I am wondering… What is "ops/sec"? How many
I'm wondering if this is possible in SQL. Say you have two tables A
I was wondering if anyone knows how could I make my own "Webpage screenshot
I am wondering what is the purpose of encoding the String: "login:password" in base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.