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

198
Views
I am tying to update Item QTY after first order but it gives me error : TypeError: ItemDB[0].setItemQTY is not a function

I'm create simple pos web application using bootstrap for my semester project but at the last steps there is few errors that I cannot correct

I can't update this Item QTY using set ItemQTY function in ItemDTO

This is My ItemDTO


function itemDTO(id,name,QTY,price) {
    const __id = id;
    const __name = name;
    const  __QTY = QTY;
    const  __price = price;

    this.getItemID = function () {
        return id;
    }
    this.setItemID = function (itemID) {
        id=itemID;
    }
    this.getItemName = function () {
        return name;
    }
    this.setItemName = function (itemName) {
        name=itemName;
    }
    this.getItemQTY = function () {
        return QTY;
    }
    this.setItemQTY = function (itemQTY) {
        QTY = itemQTY;
    }
    this.getItemPrice = function () {
        return price;
    }
    this.setItemPrice = function (itemPrice) {
        price = itemPrice;
    }
}

This is my QTYupdate function

function changeQTY() {
    let oldQty = parseInt($("#QTAvailable").val());
    let QTY = parseInt($("#QTYorder").val());
    let itemQTY = oldQty-QTY;
    for (var i in ItemDB){
        if ($("#itemNameNameDrop").val()==ItemDB[i].name){
            $("#QTAvailable").val(itemQTY);
            ItemDB[i].setItemQTY(itemQTY);
        }
    }

}

Add Item function

    let itemName = $("#itemNameNameDrop").val();
    let itemID = $("#itemID").val();
    let itemPrice = $("#itemPrice").val();
    let discount = $("#discount").val();
    let QTYavailable = $("#QTAvailable").val();
    let QTYorder = $("#QTYorder").val();
    let orderID = $("#orderID").val();

    let Item = new OrderItemDTO(itemID,itemName,QTYorder,itemPrice,orderID);

    let itemObject={
        itemID:Item.getItemID(),
        name:Item.getItemName(),
        QTY:Item.getItemQTY(),
        Price:Item.getItemPrice(),
        OrderID:Item.getOrderID()
    }

    ItemOrderDB.push(itemObject);


    countTotal();

    loadAllItemData();

    $("#tableOrder>tr").dblclick(function () {
        if (confirm("Are You Sure Want to  Delete This Row ?"))
            $(this).remove();
    });

    changeQTY();

    clearItem();

    $("#btnItemAdd").prop("disabled", true);

}

After adding item it qty value changes but when I trying to update it with set itemQTY function give me error TypeError: ItemDB[0].setItemQTY is not a function but in itemDTO I add it as function

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!