Hello,
I'm having a problem retrieving the global variable total
in a script.
In an alert inserted in the same scope it is displayed normal, but in a statement it is not returned, undefined appears. follows the excerpt:
preco = "";
qtd = "";
total = "";
function keypressed(obj, e, f) {
var tecla = (window.event) ? e.keyCode : e.which;
preco = f;
qtd = tecla - 48;
total = qtd * preco;
if (tecla == 8 || tecla == 0 || tecla == 13)
return true;
if (tecla < 48 || tecla > 57)
return false;
}
$("#confirma").confirm({
title: "Confirmação",
ERRO >>> text: "O valor total é R$" + total + ", confirmar venda?",
confirm: function(button) {
button.fadeOut(2000).fadeIn(2000);
Aqui aparece normal > alert(total);
},
cancel: function(button) {
button.fadeOut(2000).fadeIn(2000);
alert("Venda não realizada.");
},
confirmButton: "SIM",
cancelButton: "NÃO"
});
text:"O valor total é...
the value does not appear.
Any help is worth it. vlw.