Combo box value

Discussion in 'ASP General' started by TNG, Jun 11, 2005.

  1. TNG

    TNG Guest

    Hi,

    Question, I use often a combo box on my ASP pages.
    each time a form is submitted, the value of the combo box returns to the
    first selection
    But is there a way to avoid this and show always your latest selection ?

    Thx in advance

    TNG
     
    TNG, Jun 11, 2005
    #1
    1. Advertising

  2. TNG wrote:
    > Hi,
    >
    > Question, I use often a combo box on my ASP pages.
    > each time a form is submitted, the value of the combo box returns to
    > the first selection
    > But is there a way to avoid this and show always your latest
    > selection ?
    > Thx in advance
    >


    Here's one way:

    <%
    dim selection, options
    selection=request.form("cmb")
    options="<option value='a'>A</option><option value='b'>" & _
    "B</option><option value='c'>C</option>"
    if len(selection) > 0 then
    options = replace(options,"value='" & selection & "'", _
    "value='" & selection & "' selected")
    end if
    %>
    <html>
    <body>
    <form method="post">
    <select name="cmb">
    <%=options%>
    </select>
    <input type="submit">
    </form></body></html>

    HTH,
    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], Jun 11, 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. =?Utf-8?B?QW5nZWw=?=

    COMBO BOX INSTEAD OF DROP DOWN BOX

    =?Utf-8?B?QW5nZWw=?=, Jun 29, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    648
    Ken Cox [Microsoft MVP]
    Jun 29, 2004
  2. Adrian
    Replies:
    1
    Views:
    249
    Bullschmidt
    Feb 18, 2004
  3. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    622
    Bob Barrows [MVP]
    Nov 16, 2005
  4. Mike

    Combo Box and text box

    Mike, Sep 24, 2003, in forum: Javascript
    Replies:
    2
    Views:
    178
  5. SM
    Replies:
    2
    Views:
    401
Loading...

Share This Page