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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:47:34+00:00 2026-06-03T08:47:34+00:00

I would like to get the total sum of values having class addition1::: HTML

  • 0

I would like to get the total sum of values having class addition1:::

HTML CODE is

<tr >
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td class="heading">Total Inr</td>
  <td align="right" class="heading"><?php if($inr!='')echo co($inr);else echo "0.00";?>     </td>
  <td>&nbsp;</td>
  <td class="heading">ROE</td>
  <td  class="heading" ><span class="addition1"><?php if($inr!='')echo co($inr);else echo "0.00";?> </span>   </td>
  <td>&nbsp;</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td class="heading">Total Usd</td>
  <td align="right" class="heading"><?php if($usd!='')echo co($usd);else echo "0.00";?> </td>
  <td>&nbsp;</td>
  <td><input name="roe1" id="roe11" type="text" class="heading" value="1" style="width:50px" /></td>
  <td class="heading1"  style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-variant: small-caps; font-weight: bold;">
    <span class="addition1">
            <?php if($usd!='')echo co($usd);else echo "0.00";?>  </span>  
  </td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td class="heading">Total Gbp</td>
  <td align="right" class="heading"><?php if($gbp!='')echo co($gbp);else echo "0.00";?></td>
  <td>&nbsp;</td>
  <td><input name="roe1" id="roe12" type="text" class="heading" value="1" style="width:50px" /></td>
  <td class="heading2" style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-variant: small-caps; font-weight: bold;">
    <span class="addition1"><?php if($gbp!='')echo co($gbp);else echo "0.00";?></span>
  </td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td class="heading">Total Eur</td>
  <td align="right" class="heading"><?php if($eur!='')echo co($eur); else echo "0.00";?></td>
  <td>&nbsp;</td>
  <td><input name="roe1" id="roe13"  type="text" class="heading" value="1" style="width:50px" /></td>
  <td  class="heading3" style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-variant: small-caps; font-weight: bold;">
   <span class="addition1"> <?php if($eur!='')echo co($eur); else echo "0.00";?></span>
  </td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td class="heading">Total Other</td>
  <td align="right" class="heading"><?php if($other!='')echo co($other);else echo "0.00";?></td>
  <td>&nbsp;</td>
  <td><input name="roe1" id="roe14" type="text" class="heading" value="1" style="width:50px" /></td>
  <td class="heading4" style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-variant: small-caps; font-weight: bold;">
    <span class="addition1"><?php if($other!='')echo (co($other));else echo "0.00";?>    </span>
  </td>
  <td>&nbsp;</td>
</tr>

Jquery Code is

    $(document).ready(function() {
    $('#tables tbody>tr>td>input.heading#roe13').change(function() {
        var k = $('#roe13').val(); 
         $('#tables tbody>tr>td.heading3').text(function(i,v) {
            v= v.replace(/,/g, ''),
            asANumber = +v;
            x=Math.round(parseFloat(v*k)*100) / 100;
            return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");

        });
    });


$('#tables tbody>tr>td>input.heading#roe11').change(function() {
        var k = $('#roe11').val(); 
        $('#tables tbody>tr>td.heading1').text(function(i,v) {
            v= v.replace(/,/g, ''),
            asANumber = +v;                 
            x1=Math.round(parseFloat(v*k)*100) / 100;
            return x1.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
        });
    });

$('#tables tbody>tr>td>input.heading#roe12').change(function() {
        var k = $('#roe12').val(); 
        $('#tables tbody>tr>td.heading2').text(function(i,v) {
            v= v.replace(/,/g, ''),
            asANumber = +v;                 
            x2=Math.round(parseFloat(v*k)*100) / 100;
            return x2.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
        });
    });

$('#tables tbody>tr>td>input.heading#roe14').change(function() {
        var k = $('#roe14').val(); 
        $('#tables tbody>tr>td.heading4').text(function(i,v) {
            v= v.replace(/,/g, ''),
            asANumber = +v;                 
            x3=Math.round(parseFloat(v*k)*100) / 100;
            return x3.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
        });
    });


$('#tables tbody>tr').change(function() {
        var sum = 0;
        var regex = /\((\d+)\)/g;
        $('span.addition1').each(function() {       
            matches = $(this).text().replace(/,/g, ''); alert(matches);
            if( !isNaN( matches ) ){        
                sum += parseFloat(matches);
            }           
        });
    }); 
});

Class name in td can’t be changed . I am trying to get the sum of values having class addition1. On running this code, 1 value is getting skipped, e.g. If I change a value say x1 then result generated due to x1 will be skipped in addition.
Please help me out.

  • 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-06-03T08:47:35+00:00Added an answer on June 3, 2026 at 8:47 am

    Arrays in jquery are 0-based if you want the first value of matches use matches[0].

    Don’t put div’s directly inside tr’s. I’d recommend a span class="addition1" inside each of the td’s and only round the floats you wish add.

    This way you can parsefloat() first and then perform a NaN check after, stripping out all the regex stuff:

    td code:

    <td>..(<span class="addition1">1,230.0</span>)..</td>
    

    jquery loop code:

    $('span.addition1').each(function() {
     var floatVal = parseFloat($(this).text().replace(/,/g,""));
     if(!isNaN(floatVal)) {        
      sum += floatVal;
     }         
    });
    

    Use $(this).text() not .val().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get the total sum of the results in Stocks, ETFs
I would like to get the dimensions (coordinates) for all the HTML elements of
I would like to get the final SQL query, with parameter values bound (replaced)
I would like to get the sum of a column from database but the
I would like to compute sum of subtotals dynamically but i always get this
I would like to get the most out of working in cch or tcsh
I would like to get a reference to all objects in the Java heap,
I would like to get some information on list of points that needs to
I would like to get contents of some stream or project I can find
I would like to get the AssemblyCompany attribute from a WinForm project inside of

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.