# Drop down list with ability to take a new entry

**URL:** <https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752>\
**Category:** Rails\
**Created:** [January 29, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752 "2007-01-29T14:59:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 29, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752/1 "2007-01-29T14:59:22Z")

</div>

Hi there!

I’d like to build a drop down selection list that allows the user to  
a) select an alternative from a set of presets b) enter his own  
alternative if the one he’s looking for is not in the list of presets.

What’s the best way of doing that in Rails?

alex

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 29, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752/2 "2007-01-29T17:42:16Z")

</div>

There are two solutions I can think of:

- Put an option “Add new item” in the list together with other  
existing options. Use javascript to replace the select element with an  
input box in case this option is selected by the user.
- Have a standard input box and an (image) button next to it which  
would open a fake drop down list - something like those autocomplete  
things. This way user could either directly type, or click the button  
and select from the list.

The first solution would be easier to do but once user would click on  
the “Add new item”, there would be no way to go back to the list.

Anyway, it would be great, if some better Rails developer could create  
a helper for such a widget. I would be really thankful 🙂

bobes

On Jan 29, 2:58 pm, “removed\_email\_address@domain.invalid”

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 29, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752/3 "2007-01-29T19:16:00Z")

</div>

On 1/29/07, bobes [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The first solution would be easier to do but once user would click on  
> the “Add new item”, there would be no way to go back to the list.

There’s no reason why you need to get rid of the list if the user  
clicks on “Add new item…”. I would keep the list there so that if  
they select something other than “Add new item…”, it hides the text  
input box and uses the selected value from the drop down menu.

Mike

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 29, 2007, 7:37pm UTC](https://www.ruby-forum.com/t/drop-down-list-with-ability-to-take-a-new-entry/83752/4 "2007-01-29T19:37:11Z")

</div>

Yes, you are right. I thought of hiding the select box, once the input  
field appears but this is possible as well. Anyway, it would be  
wonderful to have a select box as in Microsoft Access with “not-in-  
list” event…
