# dynamic content in text\_field

**URL:** <https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237>\
**Category:** rubyonrails-talk\
**Created:** [August 5, 2011, 9:15pm UTC](https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237 "2011-08-05T21:15:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angelo\_Cordova](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Angelo\_Cordova](https://discuss.rubyonrails.org/u/Angelo_Cordova)\
**Post date:** [August 5, 2011, 9:15pm UTC](https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237/1 "2011-08-05T21:15:25Z")

</div>

Hi people

I have a problem. Maybe this is something easy, but I can't figured out with my knowledge.

To explain my problem, let's supposse I have a model call User, the DB table for users

Users -id -username -age

and a model Account, where a user has many accounts and an account belongs to user. The DB table for accounts

Account -id -user\_id -account\_name

in my form for accounts I have a collection\_select, to select a user. Then I want to have a text field for the age of the user. The idea is that when I choose a user in the collection\_select, the text\_field :age get filled automatically with the age of the user previously selected.

Which is the best approach to figured this out??

I hope you can help me, thanks

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 5, 2011, 9:33pm UTC](https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237/2 "2011-08-05T21:33:40Z")

</div>

> Which is the best approach to figured this out??

Spend a year learning javascript?

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 5, 2011, 9:53pm UTC](https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237/3 "2011-08-05T21:53:45Z")

</div>

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html)

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 8, 2011, 12:26pm UTC](https://discuss.rubyonrails.org/t/dynamic-content-in-text-field/60237/4 "2011-08-08T12:26:08Z")

</div>

[https://github.com/diwadm/ChainSelects](https://github.com/diwadm/ChainSelects)
