I have an array named weight_array. Now i want to pass it to my
javascript function abc.. How can i pass it .. May be a stupid question
but did'nt find it by googling also ..
Currently i am doing like this.
<%= radio_button "ab", "cd", { :onclick => "abc(weight_array)"; } %>
Tried this also ..
<%= radio_button "ab", "cd", { :onclick => "<%= abc(weight_array) %> ";
} %>
Tried this as well ..
<%= radio_button "ab", "cd", { :onclick => "abc(weight_array.to_json)";
} %>
Also after resolving it, i want to know that if i need to pass the ruby
array with join function ..then how can we pass ..
I mean the function [ weight_array.join(", ") .. ] ..
BTW, you should use join to make weight_array a string before passing to javascript function. You can recreate the array in javascript, if you wish, by splitting back.