"Choose from These Options, or Create a New Option"

Let’s say I have a dropdown selection list of existing teachers. The
user can (1) select any one teacher, or (2) create a new one.

How would you tackle something like that?

I’m thinking what I could do is check if there’s any data inputted into
the “new teacher” field – and if there is, create a new teacher. But,
the issue with that is the user might also have an existing teacher
highlighted, so that creates confusion – (not to mention bad
usability!)

Based on your supreme knowledge, how would you approach something like
this?

Bob S. wrote:

Based on your supreme knowledge, how would you approach something like
this?

I don’t think you should allow people to create new teachers this way -
you need to control the quality of people who teach the future!! :slight_smile:

But seriously, I’ve given the same thing some thought for one of my
applications (and haven’t yet implemented anything for it) but in my
opinion, there are a couple of main ways to do it:

  1. Have an option for ‘Other (enter below):’ and the person has to
    select that option and enter a name in the new teacher box.

  2. Use Javascript & AJAX that if such an option is selected, it darkens
    out some of the screen and shows a div that allows you to create a new
    teacher record and then updates the select box.

  3. Have a checkbox that allows you to create a new teacher. When the
    user checks it, the drop down select list is hidden and a new field is
    shown for creating a teacher.

What do you think?

Cheers,
Mohit.
8/24/2007 | 6:01 PM.

Let’s say I have a dropdown selection list of existing teachers. The
user can (1) select any one teacher, or (2) create a new one.

How would you tackle something like that?

I’m thinking what I could do is check if there’s any data inputted into
the “new teacher” field – and if there is, create a new teacher. But,
the issue with that is the user might also have an existing teacher
highlighted, so that creates confusion – (not to mention bad
usability!)

You could use auto_complete_field to have a simple text field. They
type
in the name, it pulls up a list. If they don’t like one of those
options,
they finish typing and (assuming you only need the teacher’s name) you
create a new teacher record when they submit the form.

If you need more information, I’d have a “Other/New” option in the
select
box, and have it overlay a div asking for that info like the other
poster
suggested.

Bob S. wrote:

Bob,

If you do get the AJAX one done, do consider sharing :slight_smile:

Cheers,
Mohit.
8/26/2007 | 5:03 PM.

Philip and Mohit,

Thank you for the replies! I’m going to try all of your various ideas
and see which works best. The AJAX one sounds really cool, and I think
would be very use-friendly if done right.

Of course, relying on my skills isn’t the best, so we’ll see what
happens :slight_smile:

Thanks again!

On 8/26/07, Mohit S. [email protected] wrote:

Thanks again!

Bob,

If you do get the AJAX one done, do consider sharing :slight_smile:

I do this in quite a few different places in my app… In one
instance, an Event belongs_to a venue, so I give the user the option
to select any venue from a list, or they can create a new one by
clicking on the “Create new venue…” option in the dropdown (I use a
javascript onclick handler to detect when they select the appropriate
option). I then display a hidden div which contains a form for
creating a new venue.

An event can also be associated with an artist, so I use an ajax
autocomplete field to display a list of artists. I then use something
like @event.artist =
Artist.find_or_initialize_by_artist_name(params[:artist_name]) which
will either retrieve the Artist with the given name, or it’ll create a
new instance, which will then be saved when I call @event.save.

So the Ajax code isn’t necessarily very complicated, it’s just a
standard autocomplete field and uses find_or_initialize_by_*.

Adam

Adam C. wrote:

Of course, relying on my skills isn’t the best, so we’ll see what

like @event.artist =
Artist.find_or_initialize_by_artist_name(params[:artist_name]) which
will either retrieve the Artist with the given name, or it’ll create a
new instance, which will then be saved when I call @event.save.

So the Ajax code isn’t necessarily very complicated, it’s just a
standard autocomplete field and uses find_or_initialize_by_*.

Adam

Thanks Adam!

Cheers,
Mohit.
8/29/2007 | 10:41 AM.