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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:13:44+00:00 2026-06-04T08:13:44+00:00

as you can see in the picture, it would be silly for the user

  • 0

as you can see in the picture, it would be silly for the user to have to type in all 5 Requested Brands (as that is not required). Maybe they only want to choose one Requested Brand. As it is currently set up, the subtotal is only calculated if the user enters 5 unit costs and 5 quantities…not good. If they don’t enter all 5, subtotal returns NaN.

req brands

$("a#full_sub_total").click(function(event){
  event.preventDefault();

  var first = $("div#total_result").text();
  var second = $("div#total_result1").text();
  var third = $("div#total_result2").text();
  var fourth = $("div#total_result3").text();
  var fifth = $("div#total_result4").text();

  $("#full_total_results p").text((parseInt(first,10) + parseInt(second,10) + parseInt(third,10) + parseInt(fourth,10) + parseInt(fifth,10)));

});

Any help is greatly appreciated.

  • 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-04T08:13:45+00:00Added an answer on June 4, 2026 at 8:13 am

    I would loop over the total_result fields, and incrementally add their parsed values to a total var:

    $("a#full_sub_total").on("click", function(){
      var total = 0;
      $("div[id^=total_result]").text(function(i,t){
        total += parseInt( t, 10 ) || 0;
      });
      $(".full_total").text("$" + total);
    });
    

    Note the main part of all of this:

    total += parseInt( t, 10 ) || 0;
    

    When the attempt to parse an integer from the text of the element fails, we return 0 in its place. This will not offset the total value, and will permit us to continue along with out any NaN showing up later.

    Demo: http://jsbin.com/axowew/2/edit

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

Sidebar

Related Questions

Imagine that HTML page is a game surface (see picture). User can have n
In a solution I have three projects,you can see on picture.Want to access project-1
I have a problem with layout. Look at the picture: as you can see
As you can see the picture below that when there is no item in
In this picture you can see (barely lol) that the spinner icons that rest
As you can see on the example picture, there is some type of white
I have an entity called Incident, as you can see on the picture, it
Say that I have an application where user can upload his avatar, and then
As you can see in the picture below, my UIViewController IS NOT a UINavigationController
A picture says more than a thousand words. As you can see, my fill

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.