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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:21:48+00:00 2026-06-10T16:21:48+00:00

Problem: I have a html table with 4 columns (Name, Price, Quantity, Value). The

  • 0

Problem:
I have a html table with 4 columns (Name, Price, Quantity, Value). The Quantity field has an input tag. Basically someone writes the a number in the quantity field and then hits a button and the script should multiply the Price and Quantity cell in each row and write it in the respective value cell. Then it should finally add all the Values and then write it after the table.

Seems simple enough but I can’t figure it out from the javascript / jquery documentation.

this is my html code:

<form>
<table border="0" cellspacing="0" cellpadding="2" width="400" id="mineraltable">
<tbody>
<tr>
<td valign="top" width="154">Ore</td>
<td valign="top" width="53">Price Per Unit</td>
<td valign="top" width="93">Quantity</td>
<td valign="top" width="100">Value</td></tr>
<tr>
<td valign="top" width="154"><strong>Arkonor</strong></td>
<td id="11" valign="top" width="53">1</td>
<td valign="top" width="93"><input name="12"></td>
<td id="13" valign="top" width="100">&nbsp;</td></tr>
//Lots more of these rows... all Price rows have an ID with a 1 at the end, i.e. 21, 31, 41,. ...., 
//all the text inputs have a 2 at the end of the name, and all Values have a 3 at the end.
</tbody></table></form>
<p id="result">Your value is: </p>
<button type="button">Calculate</button>
  • 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-10T16:21:50+00:00Added an answer on June 10, 2026 at 4:21 pm

    I have done a basic solution for you on jsfildde here.

    Note I cleaned up your html a bit.

    And you will have to do additional work to check for invalid inputs etc. but you should get the idea.

    Html:

        <table border="0" cellspacing="0" cellpadding="2" width="400" id="mineraltable">
        <thead>
    
    <tr>
    <td valign="top" width="154">Ore</td>
    <td valign="top" width="53">Price Per Unit</td>
    <td valign="top" width="93">Quantity</td>
    <td valign="top" width="100">Value</td></tr>
    <tr>
            </thead>
    <tbody>
    <td valign="top" width="154"><strong>Arkonor</strong></td>
    <td class="price" id="11" valign="top" width="53">1</td>
    <td class="quantity" valign="top" width="93"><input name="12" value="1"></td>
    <td class="value" id="13" valign="top" width="100">&nbsp;</td>
        </tr> 
    </tbody>
        </table>
    <p id="result">Your value is: </p>
    <button type="button">Calculate</button>​
    

    Javascript:

        $('button').click(function() {
        var total = 0;
    
        $('#mineraltable tbody tr').each(function(index) { 
    
            var price = parseInt($(this).find('.price').text()); 
            var quantity = parseInt($(this).find('.quantity input').val()); 
            var value = $(this).find('.value');
            var subTotal = price * quantity;
    
            value.text(subTotal);
            total = total + subTotal;
    
        });
    
        $('#result').text('Your value is: '+total);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is I have one html table in jsp page .And i applied
I have a big problem. I want to extract text from html table that
I have an HTML table with 3 columns and amount of text in each
I have an HTML table which may contain thousands of rows (number of columns
Here's my problem: I have an HTML table that looks like this: What I
I have an html table like this below: name number contractid sebastian 01 aea123
I have some problem using HTML tables . Below I have a table structure.
I have a problem trying to select the default value in a ComboBox (html
Hi I have problem with html height. My height is now set to pixels
I have a problem where I have some html like this <p>There is the

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.