# Rails combo box

**URL:** <https://www.ruby-forum.com/t/rails-combo-box/69155>\
**Category:** Rails\
**Created:** [September 19, 2006, 1:09am UTC](https://www.ruby-forum.com/t/rails-combo-box/69155 "2006-09-19T01:09:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thekog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3da27b/32.png) [@thekog](https://www.ruby-forum.com/u/thekog)\
**Post date:** [September 19, 2006, 1:09am UTC](https://www.ruby-forum.com/t/rails-combo-box/69155/1 "2006-09-19T01:09:22Z")

</div>

I need an editable combo box for a rails app where I can select from a  
list of values from the DB or have the user input a new one. Doing a  
plain old list box with options from the DB is easy. Can someone please  
direct me to info on the best way to do this? Will I need to resort to  
JavaScript to get it done?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![thekog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3da27b/32.png) [@thekog](https://www.ruby-forum.com/u/thekog)\
**Post date:** [September 19, 2006, 2:31am UTC](https://www.ruby-forum.com/t/rails-combo-box/69155/2 "2006-09-19T02:31:26Z")

</div>

On Mon, 2006-09-18 at 19:09, Mike K. wrote:

> I need an editable combo box for a rails app where I can select from a  
> list of values from the DB or have the user input a new one. Doing a  
> plain old list box with options from the DB is easy. Can someone please  
> direct me to info on the best way to do this? Will I need to resort to  
> JavaScript to get it done?  
> Thanks in advance.

I don’t think there’s a way to do it without Javascript.

I’ve used the one at  
[http://www.xaprb.com/blog/2005/09/29/javascript-combo-box/](http://www.xaprb.com/blog/2005/09/29/javascript-combo-box/)

And then used this in the form-

Project name  
\<%= @projects=Invoice.find\_by\_sql(["select distinct project\_name from invoices where client = ? order by project\_name",@invoice['client']]).map {|u| [u.project\_name, u.project\_name]} @projects=@projects.unshift(@invoice['project\_name']) select(:invoice, :project\_name, @projects, { }, {:onkeypress=\>"edit(event);", :onblur=\>"this.editing=false;"})%\>

–  
Sterling Web Services  
[http://www.websterling.com](http://www.websterling.com)  
The Web Done Right
