detecting same item selected again in a dropdown box

Discussion in 'Javascript' started by Andy Fish, Jun 15, 2005.

  1. Andy Fish

    Andy Fish Guest

    Hi,

    Part of my web form allows the user to select their favourite color (well it
    doesn't but it's a good example).

    There is a dropdown box with red, green, blue, and custom. When they click
    custom, a pop-up window allows them to select from other colors. This is
    done by an onclick event on the <select> element. So far so good.

    But what if they have selected a custom color and then want to change it?.
    If they drop the selector down again and re-select custom, the event doesn't
    fire again so the window doesn't pop up.

    I know it's wrong to take an action on the user selecting an item from a
    select control, but I am very tight for space on the form and I can't afford
    to put any other controls on.

    FWIW My best solution so far is to have 'custom' at the top and 'custom...'
    at the bottom. When they select the bottom one, it pops up the window and
    selects the top one.

    TIA

    Andy
    Andy Fish, Jun 15, 2005
    #1
    1. Advertising

  2. Andy Fish

    Csaba Gabor Guest

    Andy Fish wrote:
    > There is a dropdown box with red, green, blue, and custom. When they click
    > custom, a pop-up window allows them to select from other colors. This is
    > done by an onclick event on the <select> element. So far so good.
    >
    > But what if they have selected a custom color and then want to change it?.
    > If they drop the selector down again and re-select custom, the event doesn't
    > fire again so the window doesn't pop up.


    An idea for you:
    Have the top item be: "select a color" (with a label of something like
    "Color selection:")
    When the user selects a color, you replace that top item with:
    "colorName selected" and set the selectedIndex to 0. Thus, custom (not
    to mention red, green, blue) are never selected (except transiently -
    you may need to do a window.setTimeout, I forget). Plus, this way the
    user can even see what custom color they selected.

    Csaba Gabor from Vienna
    Csaba Gabor, Jun 15, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rohith
    Replies:
    3
    Views:
    5,970
    rohith
    Aug 29, 2003
  2. vishnu
    Replies:
    1
    Views:
    1,187
    Patrick.O.Ige
    Mar 25, 2006
  3. Iain
    Replies:
    3
    Views:
    918
  4. mldardy
    Replies:
    0
    Views:
    952
    mldardy
    Sep 28, 2010
  5. Replies:
    3
    Views:
    193
    Bart Van der Donck
    Jun 30, 2006
Loading...

Share This Page