Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    make combo fields stick to selection?

    I am trying to make combo fields in a form on a web page stick with the last selection. I am building the combo fields from an ASP recordset. Would there be a way with a JavaScript OnClick function to load the fields with the last selections after the Submit button is pressed? (I am staying on the same page.) Thanks in advance for ideas.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: make combo fields stick to selection?

    I don't know how many values you have, but here's how I do it. Say I have 3 values in a combo - Access 97, Access 2000, Access 2002.
    <pre><% AccessVersion = Request.Form("AccessVersion")
    Select Case AccessVersion
    Case "Access 97"
    Access97_sel = "Selected"
    Case "Access 2000"
    Access2000_sel = "Selected"
    Case "Access 2002"
    Access2002_sel = "Selected"
    End Select%>
    < ! - - .... - - >

    <select size=1 name=AccessVersion>
    <option value="Access 97" <%=Access97_sel%>>
    <option value="Access 2000" <%=Access2000_sel%>>
    <option value="Access 2002" <%=Access2002_sel%>>
    </select></pre>

    The Select Case function gives the correct variable (*_sel) the value "Selected" which is what you need to make an item appear selected in HTML.

    Please let me know if I need to explain any further.

    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: make combo fields stick to selection?

    That is a brilliant solution and I'm sure it's very, very close to what I need.

    I'm looping through the recordset to create the combo list selections, so I'm trying to wrap my brain around how to incorporate your solution. This is how I create the combo box:

    <% While Not objRSfilename.EOF %>
    <OPTION VALUE="<%=objRSfilename("BillingsMenuItem")%>">
    <%=objRSfilename("BillingsMenuItem")%></OPTION>
    <%objRSfilename.MoveNext
    Wend %>

    Thanks again.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: make combo fields stick to selection?

    Ahhh - I see now. I didn't realize you were looping through a recordset. This is even easier and your solution is very close:<pre><%BillingsMenuItem = Request.Form("BillingsMenuItem")%>
    <select size=1 name=BillingsMenuItem>
    <%Do until rst.EOF%>
    <option value="<%Response.Write(rst("BillingsMenuItem")%>"
    <%If BillingsMenuItem = rst("BillingsMenuItem") Then
    Response.Write("selected")
    End If%>>
    <% rst.MoveNext
    Loop%></pre>

    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: make combo fields stick to selection?

    I wanted to let you know that finally after these many months, I was able to get back to your solution and it works wonderfully.

    Thanks so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •