# Ajax update input fields using data from database

**URL:** <https://www.ruby-forum.com/t/ajax-update-input-fields-using-data-from-database/129928>\
**Category:** Rails\
**Created:** [February 22, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/ajax-update-input-fields-using-data-from-database/129928 "2008-02-22T20:18:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/838e76/32.png) [@keaja](https://www.ruby-forum.com/u/keaja)\
**Post date:** [February 22, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/ajax-update-input-fields-using-data-from-database/129928/1 "2008-02-22T20:18:38Z")

</div>

Does anyone have any information or links to tutorials on how to have  
a select list update other fields in a form using ajax?

Example. I have list of customers stored in a database. I would like  
to have a drop down containing a list of customers on a form, that  
when selected, would update several input fields on a form with the  
customer details from the database.

Any ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![keaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/838e76/32.png) [@keaja](https://www.ruby-forum.com/u/keaja)\
**Post date:** [February 22, 2008, 9:44pm UTC](https://www.ruby-forum.com/t/ajax-update-input-fields-using-data-from-database/129928/2 "2008-02-22T21:44:34Z")

</div>

Use the Rails observe\_field function ([http://api.rubyonrails.org/](http://api.rubyonrails.org/)  
classes/ActionView/Helpers/PrototypeHelper.html#M000966):-

Here is an example of it in use ([http://www.railshosting.org/](http://www.railshosting.org/)  
#live\_searching), obviously they are using it for a different purpose  
but the underlying logic is the same:-

1. Observe field changing
2. Make AJAX request
3. Update page element

Regards,  
Jabbslad
