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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:23:48+00:00 2026-05-27T07:23:48+00:00

I have this code which works fine for adding up input boxes. $.fn.sumValues =

  • 0

I have this code which works fine for adding up input boxes.

$.fn.sumValues = function() {
var sum = 0; 
this.each(function() {
    if ( $(this).is(':input') ) {
        var val = $(this).val();
    } else {
        var val = $(this).text();
    }
    sum += parseFloat( ('0' + val).replace(/[^0-9-\.]/g, ''), 10 );
    sum = Math.round(sum*Math.pow(10,2))/Math.pow(10,2);
});
return sum;
};

$(document).ready(function() {
$('input.money1').bind('keyup', function() {
    $('#totalsales').html( $('input.money1').sumValues() );
});

});

However I want to have seperate boxes for pound/pence (money1 for the pound boxes and money2 for pence). I have tried adding

$('input.money2').bind('keyup', function() {
    $('#totalsales2').html( $('input.money2').sumValues() );
});

But as you can tell this will add them up other 100, is there anyway I can make it add 1 to totalsales for every one hundred?

JSFiddle – http://jsfiddle.net/RZrTa/

  • 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-27T07:23:48+00:00Added an answer on May 27, 2026 at 7:23 am

    Would be better off with a jsfiddle as im not 100% sure what you mean. If can can set up an example it would help get your answer.

    But if all you want to do is take the pence value and for every 100 pence add 1 to the pounds then something like

    //-- get the pennies
    var pence = $('input.money2').sumValues();
    
    //--- get the pounds in those pennies
    var addtopounds = Math.floor(pence/100);
    
    //-- for each pound, remove 100 pennies
    pence -= addtopounds*100;
    
    //-- now pence is what you stick in the total pence box
    //-- and then the addtopounds number needs to be added to 
    //-- the value of the total pounds
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, which works fine, but I would like to be able
Hi have the following function which works fine: jQuery('.btnRemoveItem').click(function(obj){ jQuery(this).closest('li').fadeOut(400, function() { $(this).remove(); });
I have this code which compiles and works as expected: class Right {}; class
I have this code in my cfm, which works <cfif not StructIsEmpty(form)> <cfset larray
I have this code which is called at an onChange event of an function
I have this code which will include template.php file from inside each of these
I have the following format in my plist: I'm using this code which works
I have included a Search Dialog in my Activity which works fine. However adding
I have this code which gets WP posts, but it gets all the posts
I have this code (which is way simplified from the real code): public interface

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.