Results 1 to 4 of 4

Thread: Selecting the item in the dropdown list..

  1. #1

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265
    Hi there!
    I want to select (or highlight) the item in a listbox while sending back the data to the browser, which the user has selected in the listbox before sending to the server. I am able to send back all the data to the appropriate controls except the listbox (for validation purpose). Please help me.
    Either Javascript or vbscript code is ok. (and ofcourse it is a asp page)
    J£ßä

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    I'm confused. HTML Listboxes behave this way by default, there is nothing to do to get it to do what you are asking...
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    sorry!

    Hi there!
    I wanted to do server side validation. After requesting the data from the client, I am checking the data from the serverside and sending the data back to the client if any error found, so that the user may change it and re-send. But I don't know how to select or highlight the value (which the user has selected before sending to the server) of the listbox through code.
    J£ßä

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Use a HTML form to pass the data back to your page and put code at the beginning of your page that checks for the form data. If it's found process it, otherwise simply display the page as normal.

    Code:
    <HTML>
    <BODY>
    <FORM id=MyForm method=post action="MyPage.asp">
    <SELECT id=MySelect>
        <OPTION value=BLAH1>BLAH 1 BLAH</OPTION>
        <OPTION value=BLAH2>BLAH 2 BLAH</OPTION>
    </SELECT>
    <INPUT type=Submit id=MySubmit value=Submit>
    </FORM>
    </BODY>
    </HTML>
    At the top of your page:
    Code:
    <%
    If Request.Form("MySelect").Count > 0 Then
    '{Do Something with the data here}
    End If
    %>
    If you'd like to have the value still highlighted when the page is reloaded you can check the value in request.form against the value you are writing into the select tag (Presumably from a database) and add a 'selected' attribute if it is equal.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width