Forum: Ruby on Rails Drop down list with ability to take a new entry

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01c56ec01516ed2ae5c4cdac24439a25?d=identicon&s=25 notmyprivateemail2@gmail.com (Guest)
on 2007-01-29 14:59
(Received via mailing list)
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
Bdf58572897dc265e92bf19f9fbb61a5?d=identicon&s=25 bobes (Guest)
on 2007-01-29 17:42
(Received via mailing list)
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, "notmyprivateema...@gmail.com"
0900e6a4828bd989f96427082c6c74ca?d=identicon&s=25 Mike Garey (random52k)
on 2007-01-29 19:16
(Received via mailing list)
On 1/29/07, bobes <vladimir.tuzinsky@gmail.com> 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
Bdf58572897dc265e92bf19f9fbb61a5?d=identicon&s=25 bobes (Guest)
on 2007-01-29 19:37
(Received via mailing list)
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....
This topic is locked and can not be replied to.