When adding select options to input, group them using badges

0

I have the following code, which through a select is concatenated the values selected in an input, what I require to do is to place the option chosen in a badge or pager since I want it to be easier to move from position any value that I was selecting from the select

    $('#ddlVariables').change(function () {
        if ($('#ddlVariables').val() != "") {

                var textoInput = $('#txtFormula').val();
                var total = $('#ddlVariables option:selected').text();
                var nuevoTexto = textoInput + total;
                $('#txtFormula').val(nuevoTexto);            
        }
    });
<select id="ddlVariables">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

<input id="txtFormula" />
    
asked by Ivxn 18.05.2018 в 19:05
source

0 answers