Hello, there is a dynamic form, with select. I need to know exactly which values ​​were selected. That’s how I’m doing it, but only the active first element

var selection = $('.select_input').val(); 

And how to get the rest? I try an array

 var i; for (i = 0; i < selection.length; ++i) { $('#'+selection).show(); } 

But it outputs one item again, most likely the variable only contains 1 value.

Picture to understand why. On id in select already I deduce the necessary fields.

enter image description here

These are the parameters in select on all forms.

 id = types_val, class = form-control select_input 

enter image description here

    1 answer 1

     var vals = $(".select_input option:selected").map(function() { return this.value; }).get(); 

    In vals will be values ​​of the value field of the selected options for each select.

    • Thanks It works. How now to withdraw? That's the way ('#'+vals).show(); shows in 2 fields, but lonely value - Vlad Shkuta
    • vals.forEach((val) => { alert(val); }); - Suvitruf