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

  • Home
  • SEARCH
  • 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 452139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:02:33+00:00 2026-05-12T22:02:33+00:00

I have the code below that makes a list of div’s drag and droppable,

  • 0

I have the code below that makes a list of div’s drag and droppable, on drop it returns a list of the id’s in there new order.

I need to add 2 features to this code somehow.

1)
In a dropdown select list there will be 5 options. 3,6,9,12,15 and when a user picks one of these numbers I need to highlight the first X number of the div’s. if a user selects 9 I need for the first 9 div’s in the drag and drop list to change the background color so you can tell that those 9 are selected.
I also need another ajax call to be made anytime this dropdown list number is changed to save this number.
When the page is reloaded this dropdown will pull the number from a DB so if a user already had 99 saved in the DB, when they visit this page the script would show 9 in the box and have 9 div’s selected already

2)
On the drag/drop part, on drop a value like this is returned 0|1|2|3|4|5 and so on in the proper order. I need to limit this list to only return the first X amount of numbers. If the dropdown box selected 9 above then it should only save the first 9 div’s order.

Can anyone help please?

<ul id="gallery">
    <li itemID='12'>
        <div>Photo Here</div>
    </li>
    <li itemID='23'>
        <div>Photo Here</div>
    </li>
    <li itemID='32'>
        <div>Photo Here</div>
    </li>
    <li itemID='43'>
        <div>Photo Here</div>
    </li>

    ...up to hundreds
</ul>


<script type="text/javascript">

    $("#gallery").dragsort({
        dragSelector: "li div",
        dragEnd: saveOrder
    });

    function saveOrder() {
        var serialStr = "";
        $("#gallery li").each(function(i, elm) {
            serialStr += (i > 0 ? "|" : "") + $(elm).attr("itemID");
        });
        alert(serialStr);
        // $.ajax({ url: "saveorder.php/SaveListOrder", data: '{"ids":"' + serialStr + '"}', dataType: "json", type: "POST", contentType: "application/json; charset=utf-8" });
    };

</script>
  • 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-05-12T22:02:34+00:00Added an answer on May 12, 2026 at 10:02 pm

    Use this css selector:
    http://api.jquery.com/lt-selector/

    So:

    var serialStr = "";
    var list = $("#gallery li:lt(" + $("#limit").val() + ")");
    list.addClass("highlight").each(function(i, elm) { ... });
    alert(serialStr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.