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 8362777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:01:11+00:00 2026-06-09T12:01:11+00:00

I have a list that uses Jquery UI drag drop sortable but when I

  • 0

I have a list that uses Jquery UI drag drop sortable but when I drop one of options into a list I want to be able to tell where it is in the list like the following does:

http://www.webresourcesdepot.com/dynamic-dragn-drop-with-jquery-and-php/

Only thing is I am not sure how to do this around my current Jquery and when I tried I failed and it kept giving me [object] [object] errors 🙂

Here is my code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js" type="text/javascript"></script>
    <script src="js/jquery.ui.core.js"></script>
    <script src="js/jquery.ui.widget.js"></script>
    <script src="js/jquery.ui.mouse.js"></script>
    <script src="js/jquery.ui.sortable.js"></script>
<script type="text/javascript>
$( "#example1, #example2" ).sortable({
stop: function(event, ui) { 
var item = $(ui.item).parent().attr("id"); 
var moveid = $(ui.item).attr("id");
var sortableid = $(ui.item).sortable;
alert(item);
alert(moveid);
}}).disableSelection();
    });
</script>


<div class="box">
<ul id="example1" class='droptrue'>
<li id="id1" class="ui-state-default boxclass">ABC</li>
</ul>
</div>

<div class="box">
<ul id="example2" class='droptrue'>
<li id="id2" class="ui-state-default boxclass">XYZ</li>
</ul>
</div>

If any of you would be able to show me in the right direction of how to do this using javascript or jquery, I would really appreciate it.

Thank you in advance!

  • 1 1 Answer
  • 0 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-06-09T12:01:13+00:00Added an answer on June 9, 2026 at 12:01 pm

    Let’s assume our list items have a class of, ‘list_item’.

    HTML ->

    <ul>
       <li class="list_item" id="some_unique_identifier1"> List Item 197 </li>
       <li class="list_item" id="some_unique_identifier2"> List Item 3 </li>
       <li class="list_item" id="some_unique_identifier3"> List Item 55 </li>
       <li class="list_item" id="some_unique_identifier4"> List Item 104 </li>
       ...etc
    </ul>
    

    jQuery Sortable ->

    $(function(){
      $('ul').sortable({
        stop: function(event, ui){
          var list_item_id = $(ui.item).prop('id');
          var list_item_position =$(ui.item).parent().children().index(ui.item);
    
          $.ajax({
            type: 'POST',
            url: '/path/to/my/controller.ext',
            data: { 'id' : list_item_id, 'list_position' : list_item_position}
          });
        }
      }).disableSelection();
    });
    

    The PHP Controller will be the most difficult part. You’ll have to (obviously) update the row that we moved, and we’ll have to update all other rows that come after the row with +1, because, well, they’ll all gain 1 index position in the list. creating the proper workflow from here is up to you, but you have the jist of what’s needed from a jQuery Sortable perspective.

    As a side note

    And in all honesty, I probably wouldn’t send a bunch of $.ajax over to update the table I’m working with. I’d create a temporary table to store all the values, removing items that are submitted more than once so you don’t have duplicates. Then I’d require the user to save the position’s at some point with a submit button (or a per-determined interval). Then I’d update the real table with the values found in the temporary table. I’d also drop the temporary table after we’re done with it.

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

Sidebar

Related Questions

I have a form select replacement that uses jQuery to show options in a
I have an ASP.NET MVC view that uses jquery.Uploadify to post files to one
I have a form that uses jQuery-UI's selectable plugin to populate a list from
I have a jquery slideshow that that uses a navigation list to switch out
I have a standard drop-down menu that uses jQuery to hide the children li
I have used a list view that uses a grid view in WPF. I
I have a small application that uses a SharePoint list as the data source.
I have an input field that uses Autocomplete to show a list of possible
I have an app that uses a UITableView to list documents which are stored
We have a SharePoint solution that uses a standard task list. We would like

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.