Reading dropdown values in ASP

Discussion in 'ASP General' started by Martin Walke, Mar 29, 2007.

  1. Martin Walke

    Martin Walke Guest

    Hi all,

    I have an ASP application where I need to not only read the selected item
    from a combo box on a web page but also all the options in the combo box.
    Can someone point me in the right direction.

    I can obviously use request.querystring() or request.form() to get the
    selected value but not sure about how to get the options.

    TIA
    Martin
     
    Martin Walke, Mar 29, 2007
    #1
    1. Advertising

  2. Martin Walke wrote:
    > Hi all,
    >
    > I have an ASP application where I need to not only read the selected
    > item from a combo box on a web page but also all the options in the
    > combo box. Can someone point me in the right direction.
    >
    > I can obviously use request.querystring() or request.form() to get the
    > selected value but not sure about how to get the options.
    >

    Obviously, you have to store the values somewhere that is accessible to the
    code running on the web server. Possibilities inclued a database, a text
    file, an xml file, a session variable, an application variable, or some
    combination of the above.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Mar 29, 2007
    #2
    1. Advertising

  3. Martin Walke wrote:
    > Hi all,
    >
    > I have an ASP application where I need to not only read the selected
    > item from a combo box on a web page but also all the options in the
    > combo box. Can someone point me in the right direction.
    >
    > I can obviously use request.querystring() or request.form() to get the
    > selected value but not sure about how to get the options.
    >

    Oh! One possibility i neglected to mention was to use a hidden field in
    the form to store the option values, making them part of the Request.

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Mar 29, 2007
    #3
  4. Martin Walke

    Tim Slattery Guest

    "Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote:

    >Hi all,
    >
    >I have an ASP application where I need to not only read the selected item
    >from a combo box on a web page but also all the options in the combo box.
    >Can someone point me in the right direction.
    >
    >I can obviously use request.querystring() or request.form() to get the
    >selected value but not sure about how to get the options.


    You can't. When the form is submitted, one value is transmitted for a
    select group: the "value" attribute of the selected option. Nothing
    else is sent.

    If you want to know the other options in the select group, you'll have
    to do it another way: store them in a database, in the session object,
    something like that. And bear in mind, that what's transmitted for the
    selected option is not what the user sees, it's the "value" attribute.

    --
    Tim Slattery
    MS MVP(DTS)

    http://members.cox.net/slatteryt
     
    Tim Slattery, Mar 29, 2007
    #4
  5. Martin Walke

    Martin Walke Guest

    Thanks Bob.

    My line of thinking was to a hidden field anyway.

    I just wondered, although couldn't find any reference to it, whether the
    srever could access the data in some sneaky way. Obviously, if I'd thought
    it through, that client side data doesn't get transmitted in the Request.

    Martin

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > Martin Walke wrote:
    >> Hi all,
    >>
    >> I have an ASP application where I need to not only read the selected
    >> item from a combo box on a web page but also all the options in the
    >> combo box. Can someone point me in the right direction.
    >>
    >> I can obviously use request.querystring() or request.form() to get the
    >> selected value but not sure about how to get the options.
    >>

    > Oh! One possibility i neglected to mention was to use a hidden field in
    > the form to store the option values, making them part of the Request.
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
     
    Martin Walke, Mar 29, 2007
    #5
  6. Martin Walke

    Martin Walke Guest

    Thanks Tim. It was as I assumed. As per my comment to Bob, I'll use a hidden
    field populated by my validate routine.

    Martin


    "Tim Slattery" <> wrote in message
    news:...
    > "Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote:
    >
    >>Hi all,
    >>
    >>I have an ASP application where I need to not only read the selected item
    >>from a combo box on a web page but also all the options in the combo box.
    >>Can someone point me in the right direction.
    >>
    >>I can obviously use request.querystring() or request.form() to get the
    >>selected value but not sure about how to get the options.

    >
    > You can't. When the form is submitted, one value is transmitted for a
    > select group: the "value" attribute of the selected option. Nothing
    > else is sent.
    >
    > If you want to know the other options in the select group, you'll have
    > to do it another way: store them in a database, in the session object,
    > something like that. And bear in mind, that what's transmitted for the
    > selected option is not what the user sees, it's the "value" attribute.
    >
    > --
    > Tim Slattery
    > MS MVP(DTS)
    >
    > http://members.cox.net/slatteryt
     
    Martin Walke, Mar 29, 2007
    #6
    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. vishnu
    Replies:
    1
    Views:
    1,239
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    843
  3. acadam
    Replies:
    0
    Views:
    777
    acadam
    Dec 27, 2006
  4. Replies:
    2
    Views:
    458
  5. Steve Myers
    Replies:
    2
    Views:
    289
    Steve Myers
    Nov 20, 2003
Loading...

Share This Page