I need to have a select with options and JavaScript in each one,
**select...%>**
<% @buscar.each do |j|%>
<option value="<%= j.cedula_tutor1 %>" onclick="Datos2('j.cedula_tutor1');">
<%= j.cedula_tutor1 %>
</option>
<%end%>
**</select>**
This is what I have made in rails:
<%=select("cedula_tutor1", "nombre",Tutore.all.collect{|u| [u.cedula_tutor1,u.nombre_tutor1]},{}, {:onchange => "Datos2('j.cedula_tutor1'))"})%>
Of course that doesn’t work because the j.cedula_tutor1 is outside the loop. How can I make it? I just want to call a JavaScript function giving the j.cedula_tutor as parameters.
you should extend your loop with it. or just make some class variable to access it via
parentattribute of child instance. or something like caller.