Uncaught Syntaxerror: Unexpected end of input. help

Asked

Viewed 493 times

-2

$(document).ready(function(){

    if($('#license_firecorp_checkbox').is(":checked") == true){
      $("#id_license_firecorp").show();

    }

    else{
      $("#id_license_firecorp").hide();
    }

      $("#license_firecorp_checkbox").click(function(){
        if($('#license_firecorp_checkbox').is(":checked") == true){
        $("#id_license_firecorp").show();
    }
      else{
       $("#id_license_firecorp").hide();
       $("#id_license_firecorp").val('');

    }

      })

    if($('#shelf_number_checkbox').is(":checked") == true){
      $("#id_shelf_number").show();
    }

    else{
      $("#id_shelf_number").hide();
    }

   $("#shelf_number_checkbox").click(function(){
    if($('#shelf_number_checkbox').is(":checked") == true){
      $("#id_shelf_number").show();
    }
    else{
      $("#id_shelf_number").hide();
      $("#id_shelf_number").val('');
    }

      })

   if($('#envolve_process_checkbox').is(":checked") == true){
      $("#id_envolve_process").show();

    }

    else{
      $("#id_envolve_process").hide();

    }

   $("#envolve_process_checkbox").click(function(){
    if($('#envolve_process_checkbox').is(":checked") == true){
      $("#id_envolve_process").show();
    }
    else{
      $("#id_envolve_process").hide();
      $("#id_envolve_process").val('');

    }

     })


    if($('#register_employ_checkbox').is(":checked") == true){
      $("#id_register_employ").show();

    }

    else{
      $("#id_register_employ").hide();

    }

   $("#register_employ_checkbox").click(function(){
    if($('#register_employ_checkbox').is(":checked") == true){
      $("#id_register_employ").show();
    }
    else{
      $("#id_register_employ").hide();
      $("#id_register_employ").val('');

    }

    })

    if($('#external_process_checkbox').is(":checked") == true){
      $("#id_external_process").show();

    }

    else{
      $("#id_external_process").hide();

    }

   $("#external_process_checkbox").click(function(){
    if($('#external_process_checkbox').is(":checked") == true){
      $("#id_external_process").show();
    }
    else{
      $("#id_external_process").hide();
      $("#id_external_process").val('');

    }

    })

    if($('#responsability_analise_checkbox').is(":checked") == true){
      $("#id_responsability_analise").show();

    }

    else{
      $("#id_responsability_analise").hide();

    }

   $("#responsability_analise_checkbox").click(function(){
    if($('#responsability_analise_checkbox').is(":checked") == true){
      $("#id_responsability_analise").show();
    }
    else{
      $("#id_responsability_analise").hide();
      $("#id_responsability_analise").val('');

    }

    })

1 answer

2


Simply because the $(document).ready(function(){ in the last row:

$(document).ready(function(){
   if($('#license_firecorp_checkbox').is(":checked") == true){
      $("#id_license_firecorp").show();
   }
   else{
      $("#id_license_firecorp").hide();
   }

   $("#license_firecorp_checkbox").click(function(){
      if($('#license_firecorp_checkbox').is(":checked") == true){
         $("#id_license_firecorp").show();
      }
      else{
         $("#id_license_firecorp").hide();
         $("#id_license_firecorp").val('');
      }
   })

   if($('#shelf_number_checkbox').is(":checked") == true){
      $("#id_shelf_number").show();
   }
   else{
      $("#id_shelf_number").hide();
   }

   $("#shelf_number_checkbox").click(function(){
      if($('#shelf_number_checkbox').is(":checked") == true){
         $("#id_shelf_number").show();
      }
      else{
         $("#id_shelf_number").hide();
         $("#id_shelf_number").val('');
      }
   })

   if($('#envolve_process_checkbox').is(":checked") == true){
      $("#id_envolve_process").show();
   }
   else{
      $("#id_envolve_process").hide();
   }

   $("#envolve_process_checkbox").click(function(){
      if($('#envolve_process_checkbox').is(":checked") == true){
         $("#id_envolve_process").show();
      }
      else{
         $("#id_envolve_process").hide();
         $("#id_envolve_process").val('');
      }
   })


   if($('#register_employ_checkbox').is(":checked") == true){
      $("#id_register_employ").show();
   }
   else{
      $("#id_register_employ").hide();
   }

   $("#register_employ_checkbox").click(function(){
      if($('#register_employ_checkbox').is(":checked") == true){
         $("#id_register_employ").show();
      }
      else{
         $("#id_register_employ").hide();
         $("#id_register_employ").val('');
      }
   })

   if($('#external_process_checkbox').is(":checked") == true){
      $("#id_external_process").show();
   }
   else{
      $("#id_external_process").hide();
   }

   $("#external_process_checkbox").click(function(){
      if($('#external_process_checkbox').is(":checked") == true){
         $("#id_external_process").show();
      }
      else{
         $("#id_external_process").hide();
         $("#id_external_process").val('');
      }
   })

   if($('#responsability_analise_checkbox').is(":checked") == true){
      $("#id_responsability_analise").show();
   }
   else{
      $("#id_responsability_analise").hide();
   }

   $("#responsability_analise_checkbox").click(function(){
      if($('#responsability_analise_checkbox').is(":checked") == true){
         $("#id_responsability_analise").show();
      }
      else{
         $("#id_responsability_analise").hide();
         $("#id_responsability_analise").val('');
      }
   })
}) // ← FALTOU FECHAR AQUI

2 tips

first.

Instead of using

if($('#shelf_number_checkbox').is(":checked") == true)

Use

if($('#shelf_number_checkbox').is(":checked"))

The == true is unnecessary in this case.

2nd.

Instead of using

$("#id_license_firecorp").hide();
$("#id_license_firecorp").val('');

Use

$("#id_license_firecorp").hide().val('');

No need to select the same element twice in a row.

One more tip

Use the $(this) to reference the event target element. Instead of

$("#license_firecorp_checkbox").click(function(){
   if($('#license_firecorp_checkbox').is(":checked")){
      $("#id_license_firecorp").show();
   }
   else{
      $("#id_license_firecorp").hide().val('');
   }
})

Use

$("#license_firecorp_checkbox").click(function(){
   if($(this).is(":checked")){
      $("#id_license_firecorp").show();
   }
   else{
      $("#id_license_firecorp").hide().val('');
   }
})

Each byte saved code can make a difference.

  • worked, mt obg guy

  • Dispose! I added a little bit at the end of the answer. Abs!

  • @Viniciusmedeirosfogaça when a reply helps and you decide that she decided to mark her as accepted.

Browser other questions tagged

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