Sum of items when changing a record

Asked

Viewed 63 times

1

I have 3 items Accessories, Tires and Vehicles, the values are added to a maintenance screen that is the main one. The problem is that when it is to change only one of the items, the added value is just what I selected. But it is not updated with the other values

var TotalVeiculo; 
var TotalAcessorio;
var TotalPneu; 

function Somatorio(){
    TotalVeiculo = TotalVeiculo != undefined?TotalVeiculo:0;
    TotalAcessorio = TotalAcessorio != undefined?TotalAcessorio:0;
    TotalPneu = TotalPneu != undefined?TotalPneu:0;

    vmObjeto.selecionado.VlrTotalManutencao = (TotalVeiculo + TotalAcessorio + TotalPneu);
    $("#total").html("R$ " + vmObjeto.selecionado.VlrTotalManutencao + ",00");
}

function RetornoItemsa(aTela, aItens, pneu, total, quantia) {           
    var window = $(aTela).data("kendoWindow");
    window.close();

    ItensVeiculos =  aItens;
    TotalVeiculo = parseFloat(total);
    $("#btnItensVeiculos").html(" Veículos("+quantia+")");
    Somatorio();
};

function RetornoItemsb(aTela, aItens, pneu, total, quantia) {   
    var window = $(aTela).data("kendoWindow");
    window.close();
        ItensAcessoriosVeiculos =  aItens;
        TotalAcessorio = parseFloat(total);
        $("#btnItensAcessoriosVeiculos").html("Acessórios ("+quantia+")");
        Somatorio();
};

function RetornoItemsc(aTela, aItens, pneu, total, quantia) {   
    var window = $(aTela).data("kendoWindow");
    window.close();

        ItensPneusVeiculos = aItens;
        TotalPneu = parseFloat(total);
        $("#btnItensPneusVeiculos").html("Pneus ("+quantia+")");
        Somatorio();
};
  • The question is missing code. Can you do a jsFiddle and [edit] the question to put it together? So it’s easy to help.

  • Actually my problem is in this part, the retonositem a, b, and c, comes from another window all with total parameters, which will be stored in the var Vlrtotalmanutenção. Then I say that Vlrtotalmanutenion is equal to the total of all items. Let’s say I just want to add the accessory item, the other items "Tires and vehicles" can’t be added tbm. It’s like the values don’t update c.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.