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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:30:38+00:00 2026-06-18T11:30:38+00:00

Working with jQuery UI sortable to move around a list of items, and trying

  • 0

Working with jQuery UI sortable to move around a list of items, and trying to update their positions in form field values. I can’t figure out how to update a hidden input value for each item with its updated position number. All of the ‘currentposition’ values should change on each move. And the position numbers happen to be displayed in reverse order on the page.

<div id='sort-list'>
  <div id='listItem_4'>
    ITEM 4
    <input class='originalposition' type='hidden' name='item[4][origposition]' value='4'>
    <input class='currentposition' type='hidden' name='item[4][currposition]' value='4'>
  </div>
  <div id='listItem_3'>
    ITEM 3
    <input class='originalposition' type='hidden' name='item[3][origposition]' value='3'>
    <input class='currentposition' type='hidden' name='item[3][currposition]' value='3'>
  </div>
  <div id='listItem_2'>
    ITEM 2
    <input class='originalposition' type='hidden' name='item[2][origposition]' value='2'>
    <input class='currentposition' type='hidden' name='item[2][currposition]' value='2'>
  </div>
  <div id='listItem_1'>
    ITEM 1
    <input class='originalposition' type='hidden' name='item[1][origposition]' value='1'>
    <input class='currentposition' type='hidden' name='item[1][currposition]' value='1'>
  </div>
</div>

The item[#][currposition] value should be changed to the new updated position number for all items. The position value for each item should be updated, and have the correct value when the form is submitted. And the positions will be compared to the orginal values on submission.

The closest I have gotten so far is something like:

$(function() {
    $( '#sort-list' ).sortable({
        update : function () { 
            var result = $('#sort-list').sortable('toArray');
            $('input.positioncurrent').each(function() {           

            });
        }
    });
});

Thanks for the help.

  • 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-18T11:30:39+00:00Added an answer on June 18, 2026 at 11:30 am

    You should use the stop event to update the position when the sort ends.

    What I did is, when the sort ends, you retrieve the list of inputs you want to update and their numbers, and for each one you update the new position. The each() method provides the current index of the element in the list as an argument.

    $(function() {
        $( '#sort-list' ).sortable({
            stop: function () {
                var nbElems = inputs.length;
                $('input.currentposition').each(function(idx) {
                    $(this).val(nbElems - idx);
                });
            }
        });
    });
    

    Working jsfiddle

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

Sidebar

Related Questions

I'm trying to create a 3 column page with jQuery where users can move
We have a sortable list using JQuery UI Sortable that we are trying to
I'm working with a list whose items are both selectable (using checkboxes) and sortable
I'm trying to move my list item from one unordered list to another. update.js.erb
I have been trying to get JQuery Sortable working on my Zend Framework application
I'm trying to use jQueryUI draggable/droppable/sortable to move (not copy) items from a source
I'm working with a demo of two sortable jquery lists... but have a problem
I'm working with jquery. And i have text input in a form, i would
I'm working with the jQuery Sortable plugin to drag and drop images from one
I am working with jQuery UI Sortable plugin, and applying it to a table.

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.