Select multiple items from a dropdown

Discussion in 'ASP General' started by Jas, Oct 14, 2003.

  1. Jas

    Jas Guest

    I want an ASP page with a dropdown and a simple button. Every time the user
    chooses an item from the dropdown and clicks on the button i want that value
    written below in list and allow user to select more.

    Also how can these choices be saved somehow so tha when the user goes to the
    next page the choices he made can be written to the database.

    For example

    The choices in the dropdown may be

    London
    Dublin
    Paris
    New York

    When the user chooses Dublin I want ti written below the dropdown. Then when
    he chooses New York. I want it added to london. so that it displays

    Dublin
    London

    Then when he click next button these two choices are taken over to the next
    page where an insert query can be used to insert them into the db.
     
    Jas, Oct 14, 2003
    #1
    1. Advertising

  2. Jas

    Ray at Guest

    Well, one thing you could do is use a mulit-line select with the multiple
    option that will let the users select multiple options. But, that is not
    what you described. So, what you can do is post the page back to itself and
    write the value of the selected item to a hidden input on the bottom of the
    page. Then when the user selects another one and submits, add that
    selection to the input as well. Keep doing that, and then when the user
    selects the other submit button, the one that signifies he's finished, grab
    the value of the select and the hidden input(s) for all the values.

    Ray at work





    "Jas" <> wrote in message
    news:...
    > I want an ASP page with a dropdown and a simple button. Every time the

    user
    > chooses an item from the dropdown and clicks on the button i want that

    value
    > written below in list and allow user to select more.
    >
    > Also how can these choices be saved somehow so tha when the user goes to

    the
    > next page the choices he made can be written to the database.
    >
    > For example
    >
    > The choices in the dropdown may be
    >
    > London
    > Dublin
    > Paris
    > New York
    >
    > When the user chooses Dublin I want ti written below the dropdown. Then

    when
    > he chooses New York. I want it added to london. so that it displays
    >
    > Dublin
    > London
    >
    > Then when he click next button these two choices are taken over to the

    next
    > page where an insert query can be used to insert them into the db.
    >
    >
    >
    >
     
    Ray at, Oct 14, 2003
    #2
    1. Advertising

  3. Actually, I have implemented that exact scenario on one or
    two of my pages.

    Basically I have two select boxes with some size greater
    than one (so that it will display more than one line).
    Then I use javascript to copy the selected value from the
    first select box to the second.
    Then, when the page is submitted, I read the values in the
    2nd select box and populate an array with that data using
    javascript.
    Next, again using javascript, I copy the contents of the
    array to a hidden text field on the form.
    Finally, I submit the form, again using javascript.

    I know this sounds complicated, but there are no reposts,
    or roundtrips to the server except for the final posting
    of the form. The entries get added to the 2nd select box
    immediately and they all get processed at one time when
    the page gets submitted. I also have code to delete any
    entry from the 2nd select box using roughly the same
    process (in reverse).

    Note: the reason for populating the array and not the
    hidden text field directly is so that I can sort the
    entries before processing the page - makes it a little
    easier to check for duplicate entries when updateing the
    SQL database. If you don't need to sort, you could
    populate the text field directly from the select box.

    HTH,
    John



    >-----Original Message-----
    >I want an ASP page with a dropdown and a simple button.

    Every time the user
    >chooses an item from the dropdown and clicks on the

    button i want that value
    >written below in list and allow user to select more.
    >
    >Also how can these choices be saved somehow so tha when

    the user goes to the
    >next page the choices he made can be written to the

    database.
    >
    >For example
    >
    >The choices in the dropdown may be
    >
    >London
    >Dublin
    >Paris
    >New York
    >
    >When the user chooses Dublin I want ti written below the

    dropdown. Then when
    >he chooses New York. I want it added to london. so that

    it displays
    >
    >Dublin
    >London
    >
    >Then when he click next button these two choices are

    taken over to the next
    >page where an insert query can be used to insert them

    into the db.
    >
    >
    >
    >
    >.
    >
     
    John Beschler, Oct 14, 2003
    #3
    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. Jeff Tolman
    Replies:
    1
    Views:
    7,851
    Jim Cheshire [MSFT]
    Jan 7, 2004
  2. Mike
    Replies:
    1
    Views:
    825
  3. palmiere
    Replies:
    1
    Views:
    431
    Erwin Moller
    Feb 9, 2004
  4. Gumtree
    Replies:
    3
    Views:
    261
    Matt Kruse
    Nov 10, 2004
  5. Bostonasian
    Replies:
    1
    Views:
    957
    Bostonasian
    Feb 14, 2005
Loading...

Share This Page