Loop Form - extract display 'value' as well as form value?

Discussion in 'ASP General' started by Guest, Feb 20, 2006.

  1. Guest

    Guest Guest

    While I can extract the option value from the following:

    <Select name='Keystring' MULTIPLE>
    <option value='1' name='status'>Pending</option>
    .....
    </select>

    I cannot seem to extract the corresponding 'display' value when I do a
    For...Next Loop:

    for each keystring in Request.Form("Keystring")

    keystring=request("keystring")

    Next

    How do I aslo get hold of that 'display' value eg 'Pending'...is it
    possible?

    Thanks
    Jason
     
    Guest, Feb 20, 2006
    #1
    1. Advertising

  2. Guest

    Paxton Guest

    <> wrote:
    > While I can extract the option value from the following:
    >
    > <Select name='Keystring' MULTIPLE>
    > <option value='1' name='status'>Pending</option>
    > ....
    > </select>
    >
    > I cannot seem to extract the corresponding 'display' value when I do a
    > For...Next Loop:
    >
    > for each keystring in Request.Form("Keystring")
    >
    > keystring=request("keystring")
    >
    > Next
    >
    > How do I aslo get hold of that 'display' value eg 'Pending'...is it
    > possible?
    >
    > Thanks
    > Jason


    You can't. If you want to retrieve "Pending", make it the value. Why
    have you got a value of 1? Does it relate to a database key?

    Incidentally, the <option> element does not have a name attribute, so
    name='status' serves no use to you at all.

    /P.
     
    Paxton, Feb 20, 2006
    #2
    1. Advertising

  3. wrote:
    > While I can extract the option value from the following:
    >
    > <Select name='Keystring' MULTIPLE>
    > <option value='1' name='status'>Pending</option>
    > ....
    > </select>
    >
    > I cannot seem to extract the corresponding 'display' value when I do a


    Of course you can't. That is not a piece of information that is passed along
    with a form submission. Only form values are sent.

    >
    > How do I aslo get hold of that 'display' value eg 'Pending'...is it
    > possible?
    >

    Several options:
    a. Store it in a hidden field - downside: more html sent to client
    b. Create a 2-dimensional array containing all the data used to build your
    option elements. Store it in Session or Application, depending on the
    volatility of your data - downside: arrays are not easy to search without
    possibly looping through all te elements
    c. Create an xml document containing all the data used to build your option
    elements. Either store it in a file, in Session, or in Application depending
    on the volatility of the data - downside: learning curve if you've never
    used the xml parser

    Bob Barrows
    --
    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], Feb 20, 2006
    #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.

Share This Page