I am using a check_box_tag in a form_tag as follows in view_recommended_words.html.erb but it's not working:
<%= form_tag view_recommended_words_path do |f| %>
<% for keyword in @karray %>
<tr>
<td style="text-align:center; vertical-align: middle">
<%= check_box_tag "keyword_ids[]", keyword.id %>
</td>
<td style="text-align:center; vertical-align: middle">
<%= keyword.name %>
</td>
<td style="text-align:center; vertical-align: middle">
<%= collection_select(:synonym, keyword.id, keyword.synonyms, :id, :name, { prompt: true }, { id:"key", disabled: true, 'data-id' => keyword.id}) %>
<script type="text/javascript">
function Check(keyword_ids){
var array = [];
for (i = 0; i < keyword_ids.length; i++) {
if (keyword_ids[i].checked == true)
array.push(keyword_ids[i]);
}
$.ajax({
type: "POST",
url: "/developers/projects/?project_id=<%= @project.id %>"+"<%= @project.id %>"+"/get_recommended_words",
data: { array }
});
}
}
</script>
I want to store the values as an array of arrays. Ideas?