0
I have the following function.
function getValue() {
$("#SavePaper").click(function(e) {
if($(this).is(':checked')){
if ( $("input[type='radio'][name='Licenciamentodeusuários']").is(':checked') ){
valor = $('input:radio[name=Licenciamentodeusuários]:checked').val();
if(valor == "Até") {
if ($("#Ate-Comercial-MF").val() != undefined) {
qtdUsuarios = $("#Até-Comercial-MF").val();
vlrSavePaper = qtdUsuarios * 0.99;
console.log(vlrSavePaper);
}
if ($("#Até-Educacional-MF").val() != undefined) {
qtdUsuarios = $("#Até-Educacional-MF").val();
vlrSavePaper = qtdUsuarios * 0.99;
console.log(vlrSavePaper);
}
if ($("#Até-Profissional-MF").val() != undefined) {
qtdUsuarios = $("#Até-Profissional-MF").val();
vlrSavePaper = qtdUsuarios * 0.99;
console.log(vlrSavePaper);
}
if ($("#Até-Comercial-NG").val() != undefined) {
qtdUsuarios = $("#Até-Comercial-NG").val();
vlrSavePaper = qtdUsuarios * 0.99;
console.log(vlrSavePaper);
}
if ($("#Até-Educacional-NG").val() != undefined) {
qtdUsuarios = $("#Até-Educacional-NG").val();
vlrSavePaper = qtdUsuarios * 0.20;
console.log(vlrSavePaper);
}
if ($("#Até-Profissional-NG").val() != undefined) {
qtdUsuarios = $("#Até-Profissional-NG").val();
vlrSavePaper = qtdUsuarios * 0.99;
console.log(vlrSavePaper);
}
}else{
valor = valor.replace(/\s{2,}/g, ' ');
valor = valor.split(" ");
vlrSavePaper = valor[2] * 0.99;
console.log(vlrSavePaper);
}
}
}
});
}
This function is an onclick() call from a checkbox, and it looks like it’s running as if it were several clicks, by my Chrome debugging understanding.
This is the return in Chrome
In the code you put in the question, which is line 59?
– NoobSaibot
is the console.log of Until-Commercial-NG
– gabrielfalieri
In his
js-proposta-comercial.js
what’s on line 59?– NoobSaibot
console.log(vlrSavePaper); That
– gabrielfalieri
If you call the function
getValue
three times, you will associate the function in the eventclick
to checkbox three times. Food for thought.– Oralista de Sistemas
What do you mean calling it three times?
– gabrielfalieri
I understood it... it would end up not affecting the final value I believe
– gabrielfalieri