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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:48:30+00:00 2026-06-07T18:48:30+00:00

I have dynamic form like: <form id=formaa> <div class=row> <input type=text name=item class=item></input> <input

  • 0

I have dynamic form like:

<form id="formaa">
<div class="row">
  <input type="text" name="item" class="item"></input>
  <input type="text" name="quant" class="quant"></input>
  <input type="text" name="price" class="price" onkeyup="update();"></input>
  <input type="text" name="sum" id="suma" size="10" disabled="disabled"/>
</div>
<div class="row">
  <input type="text" name="item" class="item"></input>
  <input type="text" name="quant" class="quant"></input>
  <input type="text" name="price" class="price" onkeyup="update();"></input>
  <input type="text" name="sum" id="suma" size="10" disabled="disabled"/>
</div>    
<!-- ... many more rows -->
<input type="text" disabled id="total" name="tot"></input>
</form>

What I’m trying to do is multiply item quantity and price and get total sum in sum field for each item seperately (not all items total sum).

What I have achiecved is this function, but it seems counting total sum of all items together not seperately and this working with first default field row, when I add new set of fields and fill them with information both, fields (and other later added) sum values become NaN..If I remove all added field sets and leave the first form fows set, number is working again.. What is the problem here?

<script type="text/javascript">
function update() {
  var total = 0;
  $("#formaa div.row").each(function(i,o){
    total += $(o).find(".quant").val() *
        $(o).find(".price").val();
         if(!isNaN(total) && total.length!=0) {
                sum += parseFloat(total);
            }
  });
  $("#formaa div.row #suma").val(total);
}
</script>
  • 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-07T18:48:31+00:00Added an answer on June 7, 2026 at 6:48 pm
    function update() {
      $("#formaa div.row").each(function(i,o){
         var total = $(o).find(".quant").val() * $(o).find(".price").val();
         if(!isNaN(total) && total.length!=0) {
             sum += parseFloat(total);
         }
         $(o).find('[name="sum"]').val(total);
      });
    }
    

    A few problems in your code :

    • never give the same id to more than one element. That’s the reason why I defined the selector on the name
    • you weren’t resetting the total, so it was the sum of all
    • I didn’t fix that, but your operation before the float parsing is strange (it may depend on the content that I can’t see)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form like this: <form id=cform> <label>folder name:</label> <input type=text name=Folder[name] />
I have multiple inputs <input size=32 class=mixtapetrack type=text id=track[] name=track[] > <input size=32 class=mixtapetrack
Using Drupal 6.20. We can setup some form elements like this:- <input type=select name=somename[]><option>ohai</option></select>
Ok: i have a dynamic form like this: <div id=container> <div id=autosuggest>...</div> <form action=
I have a dynamic form with the following fields <tr> <td><input name = qty[]
I have a dynamic form that users can add/delete sets of input fields. I
I have form where are 2 input fields and then i have dynamic dataTables
I have... a dynamic populated select box several input boxes a submit button form
So I have a script that makes dynamic form content and each input has
So I have a script that makes dynamic form content and each input has

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.