Verify checkbox only when checked

1

I'm doing a check from a check box to see if it has a type="radio" selected. The problem is that the check is performing the calculation even when I uncheck the check box. I took the following test to see what was happening.

console.log($("input[type='checkbox'][id='SavePaper']").is(':checked') );

The test result was:

true false

false true

true false

Follow the image

WhydoesthishappenandhowdoIresolveit?

Update:checkboxcode

<div class="md-checkbox" onclick="getValue()">
     <input type="checkbox" id="SavePaper" name="SavePaper" class="md-radiobtn">
      <label for="SavePaper">
          <span class="inc"></span>
          <span class="check"></span>
          <span class="box"></span>
      </label>
</div>
    
asked by anonymous 14.08.2017 / 16:36

1 answer

0
$("#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").val() != undefined) {
                     qtdUsuarios = $("#Até-Comercial").val();
                     vlrFinal = qtdUsuarios * 0.99;
                     console.log(vlrFinal);
                 }
                 if ($("#Até-Educacional").val() != undefined) {
                     qtdUsuarios = $("#Até-Educacional").val();
                     vlrFinal = qtdUsuarios * 0.99;
                     console.log(vlrFinal);
                 }
                 if ($("#Até-Profissional").val() != undefined) {
                     qtdUsuarios = $("#Até-Profissional").val();
                     vlrFinal = qtdUsuarios * 0.99;
                     console.log(vlrFinal);
                 }
             }else{

                 valor = valor.replace(/\s{2,}/g, ' ');
                 valor = valor.split(" ");

                 vlrFinal = valor[2] * 0.99;
                 console.log(vlrFinal);

             }
         }

     }

 });

Resolved.

    
14.08.2017 / 19:49