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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:19:55+00:00 2026-06-07T15:19:55+00:00

I have html form with arrays: <form method=post id=formaa name=form> <div id=fields> <div id=divas1

  • 0

I have html form with arrays:

     <form method="post" id="formaa" name="form">

    <div id="fields">
    <div id="divas1" class="row">
<a href="#" id="did1" onClick="d(this);"><img src="d.jpg" /></a><a href="#" id="uid1" onClick="u(this);">
<img src="u.jpg" /></a><input type="text" name="ite[]" id="item" /><input type="text" name="q[]" id="quantity" class="quant" size="3" />
<input type="text" name="pr[]" id="price" size="10" class="kaina" onkeyup="update();"/><input type="text" name="sum[]" id="suma" size="10" disabled="disabled"/></div>
    </div>
    <br />
    <input type="button" name="nw" id="new" value="ADD" onClick="naujas('laukeliai');" /><br />
    Total: <input type="text" name="sumaa[]" id="suma" size="10" disabled="disabled"/>
    </form>

Each time I push forms ADD button, inside the <div id="fields"> is included new div block <div id=divas(i++)> I need multiply qp[] and pr[] values and dynamicaly add to sum field, need do multiply price and quantity of each product seperately and get final each product price (not all products total).

first tried to get all values and filter these two, but couldnt figure out…

var form = document.getElementsByName('form')[0];
var inputs = form.getElementsByTagName('input');
for (var i = 0, j = inputs.length; i < j; i++) {
    var element = inputs[i];
    alert(element.value);
}

How to extract from this array only needed values and multiply? Thanks for advices.

  • 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-07T15:19:56+00:00Added an answer on June 7, 2026 at 3:19 pm

    Assuming you want to generate the sum of the prices for all the products and quantities you bought, you would first rewrite your HTML as:

    <form id="example_form">
    <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"></input>
    </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"></input>
    </div>    
    <!-- ... many more rows -->
    <input type="text" disabled id="sum" name="sum"></input>
    </form>
    

    Use jQuery to make field access easier. Using JQuery, you would use the following JS:

    function update() {
      var total = 0;
      $("#example_form div.row").each(function(i,o){
        total += $(o).find(".quant").val() *
            $(o).find(".price").val();
      });
      $("#example_form #sum").val(total);
    }
    

    This will update totals for you. To do this each time any number is changed, you would need to register it with the corresponding fields, using something like

    $("#example_form div.row input").change(update);
    

    Have I convinced you of using JQuery? See it working at http://jsfiddle.net/UnYJ3/2/

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

Sidebar

Related Questions

I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have an HTML-form <form method=POST action= name=myform id=myform> <input type=text name=email id=email />
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
I have a HTML form that has certain fields which i am opening inside
I have built a zend form element for html content (general notes). class Sistema_Form_Note
I have a following problem, I have HTML form that uploads a file with
My input tag started to go crazy... I have html form for input to
I have a HTML form that accepts a comma separated list of tags, which
I have an html form and I need to populate one of the input
I have an HTML form which, when submitted by the user, will call a

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.