Forum: Ruby on Rails link_to_remote with javascript to fetch multiple checkboxes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
330edb8dc8bbc5a824984cf46e941b2f?d=identicon&s=25 Tam Kbe (tkbeili)
on 2009-04-27 09:49
Hello,

I'm trying to submit a link using:

<%= link_to_remote "&nbsp;&nbsp;add selected",
    :html =>{:id => 'multiple_select_form'},
    :url => { :controller => "sms",
    :action => "add_selected_to_recipients_list",
    :recipients_session_id => @recipientSessionID},
   :with => "'checked_client_array='+
document.getElementsByName('checked_client_array') "
 %>

where checked_client_array is a name of a list of checkboxes such as is:
<input type="checkbox" id="checked_client_array"
name="checked_client_array" value="<%= the_client.id %>">

what I get inside Rails console:

{"checked_client_array"=>"[object HTMLCollection]",
"recipients_session_id"=>"recipients_list"}

if I put the boxes inside regular form it works fine by I want to be
submitted from another form so that's why I'm using the :with property
for the remote link.

Any ideas what I'm doing wrong and how I can submit it regularly.

Thanks,

TAm
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-27 10:14
(Received via mailing list)
On Apr 27, 8:49 am, Tam Kbe <rails-mailing-l...@andreas-s.net> wrote:
> document.getElementsByName('checked_client_array') "
>  %>
>
Your with clause should evaluate to a query string fragment  (ie
name1=value1&name2=value2 etc...), which it doesn't in your case -
you've just got some DOM collection or something like that. You need
to construct an appropriate query string fragment from that
collection. Prototype has various helpers for dealing with this (eg
serialize).

Fred
This topic is locked and can not be replied to.