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

  • Home
  • SEARCH
  • 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 3752472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:14:47+00:00 2026-05-19T09:14:47+00:00

I have an invoice table. When I change a total amount to be paid,

  • 0

I have an invoice table. When I change a total amount to be paid, I want to update the “custom” amounts for each record in a table. My issue is that I want to only change the payment amounts on items that are selected to be paid (a checkbox is selected)

Here’s my markup

<table id="invoicetable" class="table">
    <tr>
        <th>&nbsp;</th>
        <th nowrap>Invoice</th>
        <th nowrap>Invoice Date</th>
        <th nowrap>Due Date</th>
        <th nowrap>Amount Owed</th>
        <th nowrap>Payment Amount</th>
    </tr>
    <tr id="invoice-20110106-1006-3">
        <td>
            <input checked="checked" id="select-invoice-20110106-1006-3" name="select-invoice-20110106-1006-3" title="choose to not pay anything on this invoice by unchecking this box" type="checkbox" value="true" /><input name="select-invoice-20110106-1006-3" type="hidden" value="false" />
            <input id="invoice-invoice-date-20110106-1006-3" name="invoice-invoice-date-20110106-1006-3" type="hidden" value="1/6/2011 12:00:00 AM" />
            <input id="invoice-date-due-20110106-1006-3" name="invoice-date-due-20110106-1006-3" type="hidden" value="1/5/2011 12:00:00 AM" />
            <input id="invoice-open-amount-20110106-1006-3" name="invoice-open-amount-20110106-1006-3" type="hidden" value="281.680000" />
        </td>
        <td nowrap>
            <a id="invoice-detail-link-20110106-1006-3" title="click to view invoice details" reportUrl="/Report.aspx?R=Y7QXaCujl%2fldGD1Dnc%40%2fI1B%2feDe2R5sHaszF3VEPpfd31lbsCoJ%2fh2KBORgR4dDx1N%2frHXpmd8GJljmMluJJB%4028%40tkZ%40zJLKKHflYpaLRs*" printableUrl="/Report.aspx?R=Y7QXaCujl%2fldGD1Dnc%40%2fIyRhg5x0ZGIY2AmKFLQWmSVJd1VYBWOs7HG7S0%2fw3WyUlG6lL6XS5jQZm7q1Y52DJv%2f0My5R%2fZ5Ecfet%2fREtaoc*">20110106-1006-3</a>
        </td>
        <td nowrap>1/6/2011</td>
        <td nowrap>
            <span title="this invoice is past due" class="pastdue">1/5/2011</span>
        </td>
        <td nowrap>$281.68</td>
        <td nowrap><a title="click to change payment amount" id="pay-invoice-20110106-1006-3">$281.68</a>
            <span id="invoice-payment-20110106-1006-3" style="display:none">
                <div style="float:left"><input class="small invoice-payment-amount" id="payment-amount-20110106-1006-3" name="payment-amount-20110106-1006-3" type="text" value="0" /></div> 
                <div style="float:left"><img height="1" src="/Content/Images/Spacer.png" width="6" /><img border="0" id="cancel-payment-20110106-1006-3" src="/Content/images/cross.png" style="cursor:pointer;" title="cancel changes" /></div>
                <input id="full-payment-amount-20110106-1006-3" name="full-payment-amount-20110106-1006-3" type="hidden" value="281.68" />
            </span>
        </td>
    </tr>
</table>

and here is my script

var amountTimer;
$('#Amount').keyup(function () {
    clearTimeout(amountTimer);
    amountTimer = setTimeout(function () {
        var amountString = $('#Amount').val();

        if (IsNumeric(amountString)) {
            var amount = parseFloat(amountString);

            $.each("[id^='select-invoice-']:checked", function () {
                var invoiceId = $(this).attr('id').substr('select-invoice-'.length);
                var openAmountString = $('#invoice-open-amount-' + invoiceId).val();

                if (IsNumeric(openAmountString)) {
                    var openAmount = parseFloat(openAmountString);

                    if (amount >= openAmount) {
                        $('#pay-invoice-' + invoiceId).click();
                        $('#payment-amount-' + invoiceId).val(openAmount.toFixed(2));
                        amount = amount - openAmount;
                    } else if (amount < openAmount && amount > 0) {
                        $('#pay-invoice-' + invoiceId).click();
                        $('#payment-amount-' + invoiceId).val(amount.toFixed(2));
                        amount = 0;
                    } else {
                        $(this).click();
                    }
                }
            });

        }

    }, 1000);
});

There are other events attached to items in here, like fading the entire tr when unchecked, recomputing the total when the textbox changes, and show/hide the textbox on other click events. What happens is the $.each selector works, but $(this).attr('id') returns undefined. This is odd because the selector is working based on the id.

  • 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-05-19T09:14:48+00:00Added an answer on May 19, 2026 at 9:14 am

    You should be using the other .each():

    $("[id^='select-invoice-']:checked").each(function() {
        var invoiceId = $(this).attr('id').substr('select-invoice-'.length);
        /* snip */
    });
    

    $.each() is a generic iterator function, for iterating over objects, arrays, and array-like objects.

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

Sidebar

Related Questions

I have an invoices table which stores a single record for each invoice, with
Consider we have a database that has a table, which is a record of
I have an invoice table like this: Bill Item Qty Weight Rate Amount Advance
I have an invoice table that holds the id of the user that sent
I have a table that looks like this: http://jsfiddle.net/8SEz2/4/ Branch StSeq# Inv# Invoice Date
If I have an Invoice Line Items table and a Products table, and I
Suppose we have a Invoice that is saved in a draft state in a
Assume we have an Invoice entity which has many InvoiceDetails . Each invoice detail
I have to read invoice ascii files that are structured in a really convoluted
I have a html file that has invoice details I would like to know

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.