Form elements show and Hide with jquery

Asked

Viewed 34 times

0

I have a form where 3 questions show the same part of the form, and your answers are yes or no, but when one of them is no and the other yes, it hides the form questions that are also valid for the other questions.

jQuery

 <script>
           $(document).ready(function(){
            var $profissional = $("#decorrencia-profissional"),
                $futura = $("#decorrencia-futura"),
                $sinistroIndenizado = $("#sinistro-indenizado"),
                $possuiSinistro = $(".possui-sinistro");

            $($profissional, $futura, $sinistro).change(function() {
                if($(this).val() === "Sim") {
                    $($possuiSinistro).show(1000);
                } else if $(this).val() === "Sim" && $(this).val() === "Não"{
                    $($possuiSinistro).show(1000);
                } else{
                    $($possuiSinistro).hide(1000);
                }
            });
            $($possuiSinistro).hide(1000);
        });
    </script>
  • Can you show an example with this behavior you described? joins HTML so we can help with an example to work.

  • http://www.fbnseguros.com.br/rcsorridents/index2.php

No answers

Browser other questions tagged

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