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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:27:55+00:00 2026-06-12T09:27:55+00:00

I create an Invoice. Where I put 3 fields: Quantity, Rate and Total Amount.

  • 0

I create an Invoice. Where I put 3 fields: Quantity, Rate and Total Amount. Total amount calculate following this format (Quantity*Rate). All total Amount Sum Show on Sub_total div. Here is my code:

    <html>
    <head>
        <title>Invoice</title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">

    $(document).ready(function(){

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

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

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

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


    });

    function calculateSum() {

    var qty = 1;
        $(".qty").each(function() {

            if(!isNaN(this.value) && this.value.length!=0) {
                qty = parseFloat(this.value);
            }

        });

                var rate = 0;
        $(".rate").each(function() {
           if(!isNaN(this.value) && this.value.length!=0) {
                rate = parseFloat(this.value);
            }

        });

        $('input[name=total_amount]').val(qty.toFixed(2)*rate.toFixed(2));
    }
</script>
        <style type="text/css">
table
{
    border: 1px solid black;
    border-bottom: none;
    width: 600px;
}


td
{
    border-left: 1px solid black;
    border-bottom: 1px solid black;
    padding:5px 5px 5px 5px;
}
#first
{
    border-left: none;
    border-bottom: 1px solid black;
}
        </style>
    </head>
    <body>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td id="first">Quantity</td>
                <td>Rate</td>
                <td>Total Amount</td>
            </tr>
            <?php
            $num=4;
            for ($i=0; $i<$num; $i++)
            {
                echo "
             <tr>
                 <td id='first'><input class='qty' type='text' name='qty[]'/></td>
                <td><input class='rate' type='text' name='rate[]'/></td>
               <td><input class='total_amount' type='text' name='total_amount[]'/></td>
            </tr>";
            }
            ?>
                        <tr>
                            <td id="first" colspan="2" align="right">Sub Total:</td>
            <td><span id="sub_total">0</span></td>
            </tr>
                 </table>

    </body>
</html>

I want to show each Total amount following this way

total_amount[1]=(qty[1]*rate[1])
total_amount[2]=(qty[1]*rate[1])
total_amount[3]=(qty[1]*rate[1])
total_amount[4]=(qty[1]*rate[1])

I am trying so hard but my codes don’t work properly. So pls pls pls some one help me to solve this problem.

  • 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-12T09:27:56+00:00Added an answer on June 12, 2026 at 9:27 am
    $(document).ready(function(){
        $(".qty, .rate").keyup(function(){
            calculateSum();            
        });
    });
    
    function calculateSum() {
        var qty = [];
        $(".qty").each(function() {
                var num = parseFloat(this.value) || 1;
                qty.push(num);
        });
    
        var rate = [];
        $(".rate").each(function() {
                var num = parseFloat(this.value) || 0;
                rate.push(num);
        });
        var sub_total = 0;
        $('input[name=total_amount]').each(function(i){
            var amount = qty[i].toFixed(2)*rate[i].toFixed(2);
            total += amount;
            $(this).val(amount);
        }
        $("#sub_total").text(total);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to calculate the total of an invoice. This invoice is created with
I am using the DOMPDF library to create an invoice in PDF. This document
I need to create an invoice number in format: CONSTANT_STRING/%d/mm/yyyy mm - Month (two
I'm trying to write something like this: myStub.Stub(_ => _.Create(Arg<Invoice>.It.Anything)).Callback(i => { i.Id =
I have a form in dashboard.php to create invoice and this is submitted to
I want to create a invoice as described in this post here . I
CREATE OR REPLACE FUNCTION layer2layerAttribute RETURN VARCHAR2 AS /** * This function properly joins
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
I would like to create an Invoice in HTML instead of a PDF-file. And
I need a way to create an invoice from multiple orders every month? In

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.