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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:08:13+00:00 2026-06-14T12:08:13+00:00

I’m a novice with jQuery and it probably a simple answer but I’m trying

  • 0

I’m a novice with jQuery and it probably a simple answer but I’m trying to calculate the price and quantity if a checkbox is checked. I loop through a list of items and the user selects the checkbox and enters the quantity and I’d like it to total in the last cell.

<table>
<tr>
<td width="10%">&nbsp;</td>
<td width="80%">Item</td>
<td width="10%">Price</td>
<td width="10%">Quantity</td>
<td width="10%">Total</td>
</tr>


<tr>
<td > <input type="checkbox" name="Extras" value="id" checked="no"></td>
<td >ItemName</td>
<td><cfinput type="text" name="quantity" class="quantity" size="4"></td>
<td>#Extras.Price #</td>
<td><span id="total"></span></td>
</tr>

</table>

So far I have the following for my jQuery:

$(document).ready(function() {

  $("input[type=checkbox]:checked").each (function (){
    // not sure what to put here    
  });

});

Thanks for the help!

  • 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-14T12:08:14+00:00Added an answer on June 14, 2026 at 12:08 pm

    I think you try to do something like this, check it here: http://jsfiddle.net/vNg9v/2/

    Script:

    $(document).ready(function() {
        var totalQ = $('#total-q'),
            totalT = $('#total-t'),
            valQ = 0,
            valT = 0;
        $('input:checkbox').change(function () {
            var $this = $(this),
                parentRow = $this.closest('tr'),
                totalCell =             parentRow.find('.total'),
                price = parseFloat(parentRow.find('.price').html()),
                quantity = parseFloat(parentRow.find('.quantity').val()),
                total = price * quantity;
    
    
            if ($this.prop('checked') === true)
            {
                totalCell.html(total);
                valQ += quantity;
                valT += total;
            }
            else
            {
                valQ -= quantity;
                valT -= total;
                totalCell.text('')   
            }           
            totalQ.html(valQ);
            totalT.html(valT);    
        });
    });​
    

    Html:

    <table>
        <tr>
            <td width="10%">&nbsp;</td>
            <td width="80%">Item</td>
            <td width="10%">Price</td>
            <td width="10%">Quantity</td>
            <td width="10%">Total</td>
        </tr>
        <tr>
            <td > 
                <input type="checkbox" name="Extras" value="id" />
            </td>
            <td>ItemName</td>
            <td class="price">12.10</td>
            <td>
                <input name="quantity" class="quantity" size="3" value="0" />
            </td>
            <td class="total"></td>
        </tr>
        <tr>
            <td colspan="3">TOTAL</td>
            <td id="total-q">0</td>
            <td id="total-t">0</td>
        </tr>
    </table>​
    

    Now this should be exactly what you want?

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

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into

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.