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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:44:26+00:00 2026-05-23T17:44:26+00:00

Here is a JSfiddle . I’m trying to iterate through multiple plans, and calculate

  • 0

Here is a JSfiddle.

I’m trying to iterate through multiple plans, and calculate their combined clip lengths minutes:seconds per plan. I’m missing something obvious here probably…

Here is my HTML:

<div id="right" class="active">
    <div class="plan">
        <span id="pl-title" contenteditable="true">Plan 1</span>
        <ul id="pl" class="sort">
            <li class="note yellow">
                <span id="note-title">First Clip</span>
                <span id="note-time">4:00</span>
            </li>
            <li class="note pink">
                <span id="note-title">Second Clip</span>
                <span id="note-time">0:45</span>
            </li>
       </ul>
       <span id="pl-length">Length: <span id="pl-time">0:00</span></span>
    </div>
    <div class="plan">
        <span id="pl-title" contenteditable="true">Plan 2</span>
        <ul id="pl" class="sort">
            <li class="note yellow">
                <span id="note-title">Third Clip</span>
                <span id="note-time">3:30</span>
            </li>
            <li class="note pink">
                <span id="note-title">Fourth Clip</span>
                <span id="note-time">1:18</span>
            </li>
       </ul>
       <span id="pl-length">Length: <span id="pl-time">0:00</span></span>
    </div>
</div>

Here’s my Javascript (I’m also using jQuery):

function calcTime () {
$('.plan').each(function(){
    var min = [];
    var sec = [];
    $('#pl li #note-time').each(function(){
        var data = $(this).text();
        var time = data.split(':');
        min.push(time[0]);
        sec.push(time[1]);
    });
    var totalmin = 0;
    var totalsec = 0;
    for(var i = 0; i < min.length; i++){
     var thisVal = parseInt(min[i]);
     if(!isNaN(thisVal)){
      totalmin += thisVal;
     }
    }
    for(var i = 0; i < sec.length; i++){
     var thisVal = parseInt(sec[i]);
     if(!isNaN(thisVal)){
      totalsec += thisVal;
     }
    }
    // Convert to seconds
    var m = (totalmin * 60);
    var s = (totalsec + m);
    // Convert to Min:Sec
    minv = Math.floor(s / 60);
    secv = s % 60; 
    if (secv == 0){ var secv = "00"; }

    $('#pl-time').text(minv+':'+secv);
});
}

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-05-23T17:44:27+00:00Added an answer on May 23, 2026 at 5:44 pm

    http://jsfiddle.net/ShThS/6/

    In this fiddle, i’m referencing the current ‘.plan’ div which allows the value to be calculated properly.

    Changing:

    $('#pl li #note-time').each(function(){
    

    To:

    $(this).find('#pl li #note-time').each(function(){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've re-created a simple version of what I'm trying to do here (jsFiddle) The
I have my example here: http://jsfiddle.net/bfYFq/ Column1 through Column3 divs use up 100% of
I'm trying to mimic the coverflow UI here: jsFiddle As you can see on
I have a jsFiddle here: http://jsfiddle.net/dztGA/22/ The goal: Essentially, I'm trying to have 2
If you see this JSFiddle here , I'm simply trying to animate in a
Code in here: jsfiddle Demo I wanna to get the div#content height when it
JSFIDDLE HERE On pressing a .miniimg/2/3 it should replace the src of an img
JSFIDDLE HERE If you look at the js fiddle you will find clicking the
JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user
In my jsfiddle, here: http://jsfiddle.net/SJFjK/4/ It is supposed to display a scrollbar for my

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.