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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:06:59+00:00 2026-05-13T09:06:59+00:00

I have small problem. What I want to achieve is adding sum of values

  • 0

I have small problem.

What I want to achieve is adding sum of values from above elements to each one.
For example every position have got it own time value hidden in attribute. I can get it by using jQuery

var time = $(ui.draggable).attr("time");

now we got 4 positions with time as follows:

  1. 432 sec
  2. 123 sec
  3. 5634 sec
  4. 654 sec

Now I want to sum it like this:

1. 432
2. 432+123
3. 432+123+5634
4. 432+123+5634+654

Any ideas how can I do this?

This is my code:

$(document).ready(function(){

    $(".trash").sortable({
        tolerance: 'touch',
        receive: function (event, ui) {
        ui.item.remove();
           }
    });
    $(".DragContainer_dest").sortable({helper:'clone',
        opacity: 0.5,
        connectWith: '.trash',
        scroll: true,
        update : function () { 
        var order = $('.DragContainer_dest').sortable('serialize',{key:'string'}); 
        $.post('includes/ajaxify.php',order+'&action=update');    
        var time = $(this).attr("time");
        },
        out : function () { 
            ui.item.remove();
        }
    });

    $("div[class=DragContainer] .DragBox").draggable({helper:'clone'}); 

    $(".DragContainer_dest").droppable({
        accept: ".DragBox",
        tolerance: "touch",
        drop: function(ev, ui) {
           $(this).append($(ui.draggable).clone().addClass("added"));  
        }
    });
  });

I want every element dropped or sorted in DragContainer_dest to sum values from other elements above him. Can this be done?

  • 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-13T09:06:59+00:00Added an answer on May 13, 2026 at 9:06 am

    As I can understand, you need to collect all siblings of a node that come before the element in question and collect their attributes. Let’s try this:

    var nodeSiblings = $(this).parent().children();
    // We need to find the index of our element in the array
    var stopIndex = nodeSiblings.index(this);
    var time = 0;
    
    nodeSiblings.each( function(index, element){
        if (index > stopIndex) return;
        var attribute = parseInt($(element).attr("time"), 10);
        if (!isNaN(attribute)) time += attribute;
    });
    
    // Here you have the sum of all time attributes
    alert(time);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem here. I want to list my files from a
a have a small problem when i want to skip from the first view
I have a small problem where I want to find the next active item
I'm a newbie in java and I have a small problem. I want to
I have a small problem and I do not find any solutions. I want
I have a small problem with a define. I want to assign it to
I am a Python newbie. I have this small problem. I want to print
I have a small problem: I have a List of fields, with 3 Values.
i have small problem i.e. their is one celltable with lot of data it
I have small problem with my .net 2.0 winforms application. I want to embed

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.