Thanks that worked for me. I would love to change this so I'm using a
link_to object ruby object to call this function and pass the results
to my controller rather than calling it from the Javascript object?
Here is how I ended up doing it
window.location.href=action+"?"+array_params(checked);
function array_params(arry) {
//Prototype magic... concatenating array onto variable string...
var paramvar = "";
arry.each(function(s){
paramvar = paramvar.concat("plans[]=",s,"&");});
paramvar = paramvar.replace(/&$/,"");
return paramvar;
}
It returned - plans[]=53&plans[]=52&plans[]=42
Thanks again.
Will
On Sep 15, 6:05 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On 15 Sep 2008, at 23:26, Will wrote:
>
>
>
> > I am trying to pass and array from an AJAX Javascript function to a
> > controller. The parameter is being read as a single string and not an
> > array.
>
> > The Javascript function:
> > function sendtolist(formName){
> > var form = $(formName)
> > var checked = []
> > checked = form.getInputs("checkbox","plans[]").findAll(function(item)
> > { return item.checked; }).pluck("value");
> > action="/generate_reports/advanced_plan_summary"
> > window.location.href=action+"?plans[]="+checked
> > }
>
> You need to make a query string that looks like
> plans[]=53&plans[]=52&plans[43] (to send the array [53, 52, 43])
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---