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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:08:29+00:00 2026-06-04T17:08:29+00:00

I have a form where users can create unlimited number of rows (using jquery-

  • 0

I have a form where users can create unlimited number of rows (using jquery- add new row) to add multiple products information. When they create new rows the code looks like following.

Now what I am trying to do is when every time an user puts the value of product quantity and product price I want to instantly calculate the total (product quantity* product price) and put the result in the total[] input and then adjust the total amount input which is at the bottom of the form.

I know how to do this when I have fixed amount of inputs using jquery, but since the amount of inputs are not fixed in this situation I have any idea on how to achieve this.

Could you please show me?

Thanks in Advance 🙂

 <tr>

   <td><input type="text" name="name[]" id="name_1" value=""></td>
   <td><input type="text" name="quantity[]" id="quantity_1" value=""></td>
   <td><input type="text" name="rate[]" id="rate_1" value=""></td>
   <td><input type="text" name="total[]" id="total_1" value=""></td>                        

 </tr>  

 <tr>

  <td><input type="text" name="name[]" id="name_2" value=""></td>
  <td><input type="text" name="quantity[]" id="quantity_2" value=""></td>
  <td><input type="text" name="rate[]" id="rate_2" value=""></td>
  <td><input type="text" name="total[]" id="total_2" value=""></td>                     

 </tr>  

   <!-- I have N number of rows like above. and at the bottom I have input for total -->
 <tr>

   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td><input type="text" name="totalamount" id="totalamount" value=""></td>                        

  </tr>                         
  • 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-04T17:08:32+00:00Added an answer on June 4, 2026 at 5:08 pm

    Here is one possible solution:

    $(":text[name='quantity[]'], :text[name='rate[]']").on("change", function() {
        var totalamount = 0;
        $("tr").each(function() {
            var quantity = +$(this).find(":text[name='quantity[]']").val() || 0;
            var rate = +$(this).find(":text[name='rate[]']").val() || 0;
            var subtotal = quantity * rate;
            $(this).find(":text[name='total[]']").val(subtotal);
            totalamount += subtotal;
        });
        $("#totalamount").val(totalamount);
    });​
    

    DEMO: http://jsfiddle.net/ak49E/

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

Sidebar

Related Questions

I have a form where users can add input fields with jQuery. <input type="text"
I have a form which users can add controls to and when they right
I have a form where users can modify a collection of objects using a
I have a form in witch users can add their working hours view them
I'm trying to create a form where users can save their progress. I have
I have been struggling to create a django form which users can fill and
I have a form where users create Person records. Each Person can have several
Imagine we have a page with a form where users can create their own
I have a form where users can enter the names and emails addresses of
Let's say I have a form where users can search for people whose name

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.