• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript JavaScript: Adding a Function to Calculate the Sum of Product Quantities in Orders


New Coder
Hello everyone!

I inherited an open-source program from an independent developer that manages receipts for local festivals. Among the various options, there is the so-called "digital order." Essentially, the receipts are sent from the computer to the local network, and through a web platform based on JavaScript and a website with CSS styles, the order is displayed in various departments.

I have a problem. I would like to insert a function into the JavaScript code that sounds simple to say but I find it difficult to implement: I want the SUM of the quantities of each product in the active orders to be displayed at the top of the page. Once I make the order disappear with the appropriate button, it is obviously canceled.

I'm attaching an image of the interface, and below I'm posting the part of the code that, from my limited knowledge, I believe is related to the part I want to modify.

Thanks to anyone willing to help me with this endeavor!

var lastLoad;
var orderK;
var tmrAnn;

    .ready(function () {
            .click(function () {
                if ($(this).prop("checked"))
                        $.post("/null", 'act=a_prstse&idticketl=' + $(this).attr('value'));
                        $.post("/null", 'act=a_prstsp&idticketl=' + $(this).attr('value'));
        lastLoad = $('#timestamp').attr('value');
        orderK = $('#orderk').attr('value');

function getAlert() {
    //if (orderK.length > 0) {
        $.get("/orderka.html", {timestamp: lastLoad, orderknr: orderK, now: $.now()}).done(function (data) {
            if (data.indexOf("true") > -1) {location.reload(true);}
        tmrAnn = setInterval(getAlert, 7000);

function reload() {

function getInput(name, id, page) {
    var key = '#' + id + ' input[type=text]';
    var page = '/' + page;
    var allData = '';
    $(key).each(function () {
        allData += '&' + $(this).attr('name') + '=' + $(this).val();
    data = 'act=' + name + '&id=' + id + allData;
    $.post(page, data);
    return false;
function blinker () {

setInterval(blinker, 2500);
Top Bottom