Updating a Text box

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 3

Currently, 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.

On Jun 22, 7:52 pm, Matt Y. [email protected]

<%= observe_field “person_convert”, :function => update_page {|page|
struggling as to make this dynamic. Please help.
Your rjs (ie update_page) is just generating a static blob of
javascript, it’s much easier to get rid of that crutch and just write
the javascript yourself, something like $(‘userName’).value = $F
(‘person_convert’) (assuming you are using prototype).