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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:38:04+00:00 2026-05-13T19:38:04+00:00

I have a HTML form that mimics invoice input form. This is the way

  • 0

I have a HTML form that mimics invoice input form.

This is the way I load invoice items (users select them thru autocomplete list using jQuery):

    $(document).ready(function() {
        $("#Products").focus().autocomplete('<%=Url.Action("GetProducts", "Product") %>', {
            dataType: 'json',
            parse: function(data) {
                var rows = new Array();
                for (var i = 0; i < data.length; i++) {
                    rows[i] = { data: data[i], value: data[i].product_name1, result: data[i].product_name1 };
                }
                return rows;
            },

            formatItem: function(row, i, n) {
                return row.product_PrettyId + ' - ' + row.product_name1 + ' (' + row.product_price + ' €) ';
            },
            width: 900,
            minChars: 0,
            max: 0,
            mustMatch: true
        });

        $("#Products").result(function(event, data, formatted) {
            if (data) {
                $(this).parent().next().find("input").val(data["product_id"]);
                $("#InvoiceItems > tbody").append(
                    "<tr>" +
                    "<td>num</td>" +
                    "<td>" + data["product_PrettyId"] + "</td>" +
                    "<td>" + data["product_name1"] + "</td>" +
                    "<td>" + data["product_price"] + "</td>" +
                    "<td></td>" +
                    "<td>1</td>" +
                    "<td>" + data["product_price"] + "</td>" +
                    "</tr>");
            }
        });

After each invoice item added I need to enumerate the table that I’m building – count the items, multiply price with quantity and sum all the items.

How can I do that?

  • 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-13T19:38:04+00:00Added an answer on May 13, 2026 at 7:38 pm

    You might want to add some classes to specific tds for things like quantity, price, and with the total number of items, each time you add a new one you can update a counter and store it within a hidden field and read from that value

    EDIT: wrap .each loop in function

    function functionName() {
    var itemCounter = 0;
    $('#InvoiceItems tr').each(function() {
        itemCounter += 1;
        //this loops through each row in the table
        var quantity = parseFloat($('td.quantity', this).text());
        quantity = isNaN(quantity) ? 1 : quantity;//if a number isn't parsed, replace it with 1
        var price = parseFloat($('td.price', this).text());
        price = isNaN(price) ? 0 : price;
        var total = quantity * price;
        //do something with the total
    });
    }
    

    you could call this function whenever a new item is added so the totals will always be up to date

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

Sidebar

Related Questions

I have an HTML form that needs multiple submit buttons, like this: <input type=submit
I have an HTML form that looks like this: <form action=index.php method=post> <input type=hidden
I have HTML that looks like this: <form id=kinodForm> <input type=text name=element[5] value=krispy kreme
I have an html form that looks something like this: <div class=field> <input id=product_name
Okay, next PHPExcel question. I have an HTML form that users fill out and
I have a simple html form that is structured something like this: <form name=test
I have an html form that has the following structure: <input type=text name=title />
For instance, I want to have a html form that looks like this: <table>
I do have an html form that accepts textbox input of sha1 hashes per
I have html in my form that looks like this. First, is this code

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.