All pastes #402504 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-19 22:45 UTC
rendered paste body
function total()
{
    // MATERIAL
    
    
    // precos
var prs1 = document.cliente_form.prs1.value;
var prs2 = document.cliente_form.prs2.value;
var prs3 = document.cliente_form.prs3.value;
var prs4 = document.cliente_form.prs4.value;
var prs5 = document.cliente_form.prs5.value;
// não permitir valores nulos
if (prs1 == "" || document.cliente_form.prs1.lenght == 0){prs1 = 0}else{prs1=parseFloat(document.cliente_form.prs1.value) };
if (prs2 == "" || document.cliente_form.prs2.lenght == 0){prs2 = 0}else{prs2=parseFloat(document.cliente_form.prs2.value) };
if (prs3 == "" || document.cliente_form.prs3.lenght == 0){prs3 = 0}else{prs3=parseFloat(document.cliente_form.prs3.value) };
if (prs4 == "" || document.cliente_form.prs4.lenght == 0){prs4 = 0}else{prs4=parseFloat(document.cliente_form.prs4.value) };
if (prs5 == "" || document.cliente_form.prs5.lenght == 0){prs5 = 0}else{prs5=parseFloat(document.cliente_form.prs5.value) };

// quantidades
var qtd1 = document.cliente_form.qtd1.value;
var qtd2 = document.cliente_form.qtd2.value;
var qtd3 = document.cliente_form.qtd3.value;
var qtd4 = document.cliente_form.qtd4.value;
var qtd5 = document.cliente_form.qtd5.value;
// não permitir valores nulos
if (qtd1 == "" || document.cliente_form.qtd1.lenght == 0) { qtd1 = 0 } else { qtd1 = parseFloat(document.cliente_form.qtd1.value) };
if (qtd2 == "" || document.cliente_form.qtd2.lenght == 0) { qtd2 = 0 } else { qtd2 = parseFloat(document.cliente_form.qtd2.value) };
if (qtd3 == "" || document.cliente_form.qtd3.lenght == 0) { qtd3 = 0 } else { qtd3 = parseFloat(document.cliente_form.qtd3.value) };
if (qtd4 == "" || document.cliente_form.qtd4.lenght == 0) { qtd4 = 0 } else { qtd4 = parseFloat(document.cliente_form.qtd4.value) };
if (qtd5 == "" || document.cliente_form.qtd5.lenght == 0) { qtd5 = 0 } else { qtd5 = parseFloat(document.cliente_form.qtd5.value) };
// resolver
document.cliente_form.psi1.value = ((prs1 * qtd1) + (prs2 * qtd2) + (prs3 * qtd3) + (prs4 * qtd4) + (prs5 * qtd5));

total =  ((prs1 * qtd1) + (prs2 * qtd2) + (prs3 * qtd3) + (prs4 * qtd4) + (prs5 * qtd5));


// Deslocacao

var qtdmao = document.cliente_form.preco_qtd2.value;
var psimao =  document.cliente_form.psi6.value;

if(psimao = "" || document.cliente_form.preco_qtd2.lenght == 0)
{
    if(qtmao == "" || document.cliente_form.psi6.length == 0)
    {
       document.cliente_form.preco_qtd2.value = 0
       document.cliente_form.psi6.value = 0
    }
    else
    {
       document.cliente_form.preco_qtd2.value = 0
       document.cliente_form.psi6.value = 0    
    }
}
else
{
    if(qtmao == "" || document.cliente_form.psi6.length == 0)
    {
       document.cliente_form.preco_qtd2.value = 0
       document.cliente_form.psi6.value = 0
    }
    else
    {
        var quanto = parseFloat(document.cliente_form.preco_qtd2.value)
        var valor = parseFloat(document.cliente_form.psi6.value)
        
        total += valor + quanto
    }
}


document.cliente_form.totalfinal.value = total;
}