I have a page with a collection_select, populated by an array of info
pulled form a MySQL table. Trying to get some text_fields to update
with information from this array depending on which item was selected
from the collection select.
Here is some view code:
<%= collection_select(:person, :convert, @nonUsers, :id, :fullName,
{:prompt => “Choose…”}, :style => “width:125px;”) %>
<%= text_field_tag :userName, @userName %>
<%= observe_field “person_convert”, :function => update_page {|page|
page[“userName”].value = @nonUsers[2].fullName }%>
Which will populate the list with HTML as follows:
Person 1 Person 2 Person 3Currently, with the @nonUsers[2].fullName section i’m able to get the
text_field to populate with the fullName of the second item, but i’m
struggling as to make this dynamic. Please help.