Open javascript with Select Option

0

I want to open openVit () and openVilla () when the select option is pressed.

<select>
<option href='javascript:;' onchange="abrirVit();" value="canto">Vitória - Praia do Canto</option>
<option href='javascript:;' onchange="abrirVelha();" value="velha">Vila Velha</option>
</select>

SCRIPT:

 <script type="text/javascript">
    $(function(){
    function abrirVit(){
        $("#backForm").css("display","block").stop().animate({"opacity":"1"},200);
        setTimeout(function(){
            $("#formContact").css("display","block").stop().animate({"opacity":"1"},200);
        },150);
    };
</script>



  <script type="text/javascript">
        $(function(){
        function abrirVelha(){
            $("#backForm").css("display","block").stop().animate({"opacity":"1"},200);
            setTimeout(function(){
                $("#formContact").css("display","block").stop().animate({"opacity":"1"},200);
            },150);
        };
    </script>
    
asked by anonymous 19.09.2016 / 22:26

1 answer

1

I CAN MAKE IT WORK.

 <select id="opcoes">
                              <option value="selecione">Selecione uma unidade</option>
                              <option value="canto">Vitória - Praia do Canto</option>
                              <option value="velha">Vila Velha</option>
    </select>

script

  $('#opcoes').on('change', mudou);

    function mudou() {
        if ($('#opcoes').val() == 'canto'){
                 $("#backForm").css("display","block").stop().animate({"opacity":"1"},200);
        setTimeout(function(){
            $("#formContact").css("display","block").stop().animate({"opacity":"1"},200);
        },150);
        }
        else if ($('#opcoes').val() == 'velha'){
                $("#backForm").css("display","block").stop().animate({"opacity":"1"},200);
        setTimeout(function(){
            $("#formContact").css("display","block").stop().animate({"opacity":"1"},200);
        },150);
        }
    }
    
20.09.2016 / 20:52