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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:12:06+00:00 2026-06-07T21:12:06+00:00

Im using the following method to add up text boxes. I have tried changing

  • 0

Im using the following method to add up text boxes. I have tried changing multiple things and cant seem to multiply two text box values! essential I want 2 text box that values are multiplied and displayed in a third text box. I want this value to be fluid aka change when the number changes! I was using this code because i may be multiplying more then one thing but if this is too much of a hassle i will live with just multiplying two at a time

The code im using to add is

 <!--adding script #-->    
 <script>

$(document).ready(function(){
    calculateSum();

    //iterate through each textboxes and add keyup
    //handler to trigger sum event

    $(".txt").each(function() {

        $(this).keyup(function(){
            calculateSum();
        });
    });

});

function calculateSum() {

    var sum = 0;


    $("#sum").val(sum.toFixed(2));
    //iterate through each textboxes and add the values
    $(".txt").each(function() {


        //add only if the value is number
        if(!isNaN(this.value) && this.value.length!=0) {

            sum += parseFloat(this.value);
        }

    });
    //.toFixed() method will roundoff the final sum to 2 decimal places
    $("#sum").html(sum.toFixed(2));

      var total = document.getElementById("subtotal").value == "";
     var total = document.getElementById("subtotal").value = sum;
             }
    <!--END adding script #-->   

I tried setting the last line to

      var times1 = document.getElementById(subtotal);
      var times2 = document.getElementById(tax);
  var equal = times1.value * times2.value;

and then changing var total1 = document.getElementById(“total1”).value = sum9; to var total1 = document.getElementById(“total1”).value = equal;

The text boxes id are subtotal and tax the box im trying to update is total1.

Thanks alot!

  • 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-07T21:12:08+00:00Added an answer on June 7, 2026 at 9:12 pm

    On every keyup, instead of getting all values and adding them explicitly, it is better to deduct the previous value of the corresponding input and add the current updated value to sum..

    Also, if subtotal is correctly calculated, then the multipication operation what ever you have done should work correctly..

    Please find the following jsfiddle where the sum is calculated as explained above along with multiplying the tax..

    http://jsfiddle.net/tgvrs_santhosh/77uxK/1/

    Let me know if you still face the issue..

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

Sidebar

Related Questions

I am using the following script to add default values to input text boxes:
How can i generate multiple texts using the imagecreatetruecolor() method? I have the following
I have following method which I am using to load ActiveX control dynamically, Dim
Using the following code I want to add an icon to the text link
You can add as many text boxes as you want as shown by using
I've concatenated string using the following code: NSString *add = @a ; lbl.text =
I have populated datagridview using the following method and I have added button column
I am using following method to get bitmap from url but image is not
I am using the following method to reverse geocode a google maps latlng: [GClientGeocoder.getLocations(address:String,
I am using the following method to basically create a JSON string. var saveData

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.