I'm trying to send an array for use in javascript from html with a Ruby's variable like this:
<% @data.each do |d| %>
<input type="hidden" id="name" value= "<%= d.name %>">
<% end %>
"data" is a variable of a model
def index
@data = organizations.all
end
in js i used a variable with id "name"
var nombre = document.getElementById("name").value;
var x = name;
I want that x is an array like:
["Org1","Org2","Org3"]
thanks for everything