fill in a selection from an input

-2

Friends I need to fill out a selection from a text box that is hosted in an input

the idea is to enter the txt_nameSector and be able to select that sector in the table next

    
asked by daniela zañartu 01.12.2018 в 03:12
source

1 answer

0

As I understood, it requires filling a select with text that you enter in input , an example that served me is this:

An empty selection, plus an input and a button

  $(document).ready(function () {
      //Al hacer click se recupera el texto y se añade en el select
      $("#btnSave").click(function () {
          var texto = $('.frase').val();
          $('.combo').append(new Option(texto));
      });
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<select class="combo">
  
</select>

<input type="text" class="frase">
<button id="btnSave">Save Click</button>
    
answered by 01.12.2018 в 04:15