Open div according to combo selection

0

I need to include rows in a table with textbox fields according to combo selection.

The x is that if the user selects in the Employees combo = 2, it should display the Name 1 and Name 2 textbox, if you select Employees = 3, it displays the Name 1, Name 2, and Name 3 rows, up to the limit of 5.

I have seen some posts but always show 1 to 1 (such as: Display hidden div according to the value of a Dropdown )

    
asked by anonymous 23.02.2016 / 19:21

1 answer

1
    $(document).ready(function(){
    //Chama o evento após selecionar um valor
    $('#DropEmpregados').on('change', function() {
    //Verifica a numeração do select no dropdown
      if ( this.value == '2')
      {
            $("#divNome1").show();
        $("#divNome2").show();
      } 
      else if( this.value == '3')
      {
          $("#divNome1").show();
          $("#divNome2").show();
          $("#divNome3").show();
      }
      else if (this.value == '4')
     {
          $("#divNome1").show();
          $("#divNome2").show();
          $("#divNome3").show();
          $("#divNome4").show();
     }
      else if (this.value == '5')
    {
          $("#divNome1").show();
          $("#divNome2").show();
          $("#divNome3").show();
          $("#divNome4").show();
          $("#divNome5").show();
    }
        //Se não for nenhuma das alternativas ele esconde todas
        else{
             $("#divNome1").hide();
             $("#divNome2").hide();
             $("#divNome3").hide();
             $("#divNome4").hide();
             $("#divNome5").hide();
        }
    });
});

From what I understood and based on the logic of the link example, would that be? It can be done using the css script in several ways ... But I think that example you gave the link already left you in the face of the goal. Give a return and a greater clarification in this doubt if it is certainly not

    
23.02.2016 / 20:03