Accessing the selected item select_tag
Well, I have multiple select_tags (values ββare generated from a split single row):
<% @item.item_options.each do |x| %>
<% if !x.value.empty? && !x.option.empty? %>
<div class="row"> <%= x.option %> : <%= select_tag :values, options_for_select(x.value.split(',')) %></div>
<% end %>
<% end %>
I am trying to concatenate only selected values ββfrom each into one line. And separate them with a spatial symbol and pass it to another controller.
I am using hidden_filed to send values, but I cannot access the selected values ββto perform concatenation!
<%= f.hidden_field :values, :value => ??? %>
+3
source to share
1 answer
You can use jquery to get the selected value of the select:
$('select option:selected').val();
If I understand your question correctly.
To get all selected items of items from all select items take a look here:
Get all selected item elements from all select items on a form
0
source to share