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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:14:35+00:00 2026-05-28T00:14:35+00:00

I have a text box at top which displays the total duration. Now what

  • 0

I have a text box at top which displays the total duration. Now what happens is the user selects a duration from a timepicker and this will be displayed in the textbox and then add it into a new row.
Now the situation I have is that the format of the textbox is like this “00 Hrs 00 Mins 00 Secs”.

So for example if the total duration was 00 Hrs 30 Mins 00 Secs and if you select 00 Hrs 20 Mins 00 Secs from the timeicker (displayed in the textbox) and then add it into a new row, then 00 Hrs 30 Mins 00 Secs should minus 00 Hrs 20 Mins 00 Secs to make 00 Hrs 10 Mins 00 Secs.

The thing is that I know how to do the calculation but I do not how to match it with in the 00 Hrs 00 Mins 00 Secs format. My calculation works for a normal number format but how can I get it working with this format?

    Below is my jquery code which does the calculation:

var duration = '<?php echo $_POST['durationChosen']; ?>'

        $("#qandatbl td.duration input").live("change", function(){
            calculateDuration();
        });

        function calculateDuration()
        {
           var totalduration = duration;  
    //duration is the variable which displays total duration e.g 00 Hrs 30 Mins 00 Secs
           $("#qandatbl td.duration input").each(function (i, elm){
                totalduration = totalduration - parseInt($(elm).val(), 10);
            });

            $("#total-duration").text(totalduration);
        }

Below is html code:

    <table id="questionDuration">
    <tr>
         <th colspan="2">
         Question Duration
         </th>
    </tr>
    <tr>
    <td><input type="text" id="questiondurationpicker" name="questionDuration" readonly="readonly" /></td>
    // timepicker textbox for duration
    </tr>
    <tr>
    <td>Total Duration Remaining: <span id="total-duration"></span></td>
    this is where the total duration is displayed
    </tr>
    </table>


    <table id="qandatbl" border="1">
    <tr>
        <th class="duration">Question Duration</th>
    </tr>
    </table>

    // above is where the duration selected is stored in a new row
  • 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-28T00:14:36+00:00Added an answer on May 28, 2026 at 12:14 am

    EDIT:


    Look at this fiddle.

    http://jsfiddle.net/pixelass/URLR5/15/

    http://jsfiddle.net/pixelass/URLR5/16/ (faster version)

    http://jsfiddle.net/pixelass/URLR5/17/ (force two digits e.g 9 = 09)

    HTML

    current Time: <span id="currentTime">25 Hrs 24 Mins 45 Secs</span>
    <hr>
    subtract Time: <span id="minusThis">07 Hrs 15 Mins 21 Secs</span>
    <hr>
    new Time: <span id="newTime"></span>
    <hr>
    
    <button>subtract the time</button>
    

    jQuery

    var minusThis = $('#minusThis').text(),
        date = minusThis.match(/(\d\d)/ig),
        currentTime = $('#currentTime').text(),
        newDate = currentTime.match(/(\d\d)/ig),
        newsetH = parseInt(date[0], 10),
        newsetM = parseInt(date[1], 10),
        newsetS = parseInt(date[2], 10),
        hours = parseInt(newDate[0], 10),
        mins = parseInt(newDate[1], 10),
        secs = parseInt(newDate[2], 10);
    
    
    function calculate() {
        newH = hours - newsetH;
        newM = mins - newsetM;
        newS = secs - newsetS;
        $('#newTime').text(newH + ' Hrs ' + newM + ' Mins ' + newS + ' Secs');
    }
    
    $('button').on('click', calculate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with a text input box which displays similar entries to
I am making an algorithm builder and have a main text box on top,
I have text box in which your adds values in comma separated values. Once
i have form where i have text box value and link (add). when user
I have a text box which has a Ajax calendar extender attached. You click
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have a text box with a certain width and a string. How do
I have one text box and i have to show minimum date of the
I have a text box that is going to be populated with a comma
I have a text-box, and I want to enter a string in language A

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.