Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
add comment (requires an account with 50 reputation)

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.