Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
How to delete line and update totals in Javascript

Here is what I'm trying to do.

I'm trying to delete a line item and update the order with the current code:

The HTML code:

<div class="invoice-billing">
    <div class="invoice-billing-item"><input type="text" class="form-control" id="sku-%ID%" name="sku-%ID%" /></div>
    <div class="invoice-billing-item"><input type="text" class="form-control" id="description-%ID%" name="description-%ID%" /></div>
    <div class="invoice-billing-item">
        <label class="switch" for="taxable-%ID%" style="margin-left: 4px; top: 4px;">
            <input type="checkbox" class="taxable-%ID%" name="taxable-%ID%" id="taxable-%ID%" />
            <div class="slider round gray"></div>
        </label>
    </div>
    <div class="invoice-billing-item"><input type="text" onchange="updateInvoiceValue()" class="form-control invoice-billing-qty" id="qty-%ID%" name="qty-%ID%" /></div>
    <div class="invoice-billing-item"><input type="text" onchange="updateInvoiceValue()" class="form-control invoice-billing-unit-price" id="unit-price-%ID%" name="unit-price-%ID%" /></div>
    <div class="invoice-billing-item invoice-billing-item-ext-price">
        <div id="ext-%ID%"></div>
    </div>
    <a class="invoice-billing-item-trash" id="del-%ID%" name="del-%ID%" onchange="updateInvoiceValue()"><i class="fas fa-trash-alt"></i></a>
</div>

Here is the JavaScript code:

function updateInvoiceValue() {
    for (var i = 1; i < newInvoiceIndex; ++i) {
        $("#del-" + i).on("click", function () {
            var quantity = parseInt($("#qty-" + i).val());
            var unitPrice = Number($("#unit-price-" + i).val());
        });
    }
}

The problem is that I'm getting a NaN on the numeric fields even though there is a value on the field. How can I get the values of the numeric fields and remove an line item? I pretty much know how to update the totals

Thank you...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!