I have a form (form_for), and I want the user to be able to select multiple "categories" using the select method.
= form_for @place, :url=>{:action=>"#"} do |f|
Every time a user selects a category, I have jQuery, add a div with the category value so that users can see and delete the categories that they added.
$('#hotel_categories').change(function(){ value = $(this).val(); $('#appended_wrapper').append( '<div class="appended"> '+value+' <a class="remove" href="#">Remove</a></div>' ); $('.remove').click(function(){ $(this).parent(".appended").remove(); }); });
When I click the submit button, I want all the selected categories to be passed to my controller in an array.
How do I achieve this?
Thanks.
source share