Drop down list with ability to take a new entry

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

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 :slight_smile:

bobes

On Jan 29, 2:58 pm, “[email protected]

On 1/29/07, bobes [email protected] 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

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs