Java script on classic ASP page

Discussion in 'ASP General' started by paulmitchell507, Aug 12, 2008.

  1. I have the following Java script on a asp page located on my company
    intranet.

    <html>
    <head>
    <title>Example combo box</title>
    <script language="javascript">
    <!--
    function dept_onchange(frmSelect) {
    frmSelect.submit();
    }
    //-->
    </script>
    </head>
    <body>
    <form name="frmSelect" method="Post" action="select.asp">
    <SELECT name=courses LANGUAGE=javascript onchange="return
    dept_onchange(frmSelect)">
    <%
    Set oRs=Server.CreateObject("adodb.recordset")
    strSQL = "SELECT Status_ID, Staff_ID, firstlastName FROM staff
    WHERE
    Status_ID=1 Or Status_ID=19 ORDER by firstlastname"
    oRs.Open strSQL, conn

    Do while not oRs.EOF
    if Request.Form("courses") = oRs("firstlastName") then
    'if this is
    the selected one then display as selected
    Response.Write "<OPTION VALUE = '" & oRS
    ("staff_ID") & "'
    SELECTED>"
    Response.Write oRs("firstlastName") & "</
    Option>"
    oRs.MoveNext
    else
    Response.Write "<OPTION VALUE = '" & oRs
    ("Staff_ID") & "'>"
    Response.Write oRs("firstlastName") & "</
    Option>"
    oRs.MoveNext
    end if
    loop

    Could somebody tell me if it's possible to display the selected
    "firstlastname" on the page? At the moment after the user makes a
    selection the page is refreshed and the default 'firstlastname' is
    displayed. The staff_ID value is stored in request.form("courses")
    which is then posted to another ASP page but the user has no way of
    telling which 'firstlastname' they selected.

    My initial thoughts were to run a SQL statement using the staff_iD
    held in request.form("courses") to retrieve and display the
    'firstlastname'. But I don't think that will work.

    Any help would be appreciated.
    Classic ASP, Access 2K DB
     
    paulmitchell507, Aug 12, 2008
    #1
    1. Advertisements


  2. In the other thread with an identical question I asked you why you were
    doing the above??

    If you can answer that we can move forward. BTW, starting another thread is
    a little annoying.
     
    Anthony Jones, Aug 12, 2008
    #2
    1. Advertisements

  3. I assumed that as I had not replied to your post for such a long time
    that the original thread was dead, I do apologise.
    I am attempting to create a internal holiday request application. I
    am using the javascript to provide a drop down list, the user can then
    select his/her name from the list.

    The corresponding staff_ID is then passed to the next asp page for
    entry into the database. I just want the user to be able to see on
    screen that they have selected the correct entry from the list. At
    the moment, the screen is refreshed after the selection has been made.
     
    paulmitchell507, Aug 12, 2008
    #3
  4. Paul,

    When you ask for help you will most likely get responses that ask you
    questions so that what you are doing is better understood and the help can
    be more targeted. Its very frustating trying to help someone when they
    won't answer the questions posed to them. I'd like to help further but
    unless I know the answer to the above question I'm afraid I can't.
     
    Anthony Jones, Aug 12, 2008
    #4
  5. Sorry, we have not got off on a very good footing here!
    Why have I done the above? Because I was looking for an example of a
    drop down box that would display the 'firstlastname' field but pass
    the staff_ID field. This was the first example I found that appeared
    to work. If you have an alternative solution I would be more than
    happy to change the code above.
     
    paulmitchell507, Aug 12, 2008
    #5
  6. You're still missing the point. Anthony is asking about this specific
    function:


    Why are you wanting to submit the form when the listbox selection
    changes?
    It appears the answer is that you have copy/pasted this html from
    somewhere and you do not know why the code was written to cause the form
    to be submitted when the selection changed. is that correct?
     
    Bob Barrows [MVP], Aug 12, 2008
    #6
  7. You are correct to say that I do not know why the code was written to
    cause the form to be submitted when the selection changed. Is it
    possible that the page needs to be submitted each time a selection is
    changed so the corrasponding staff_ID is placed in
    request.form("courses")? If I was to select user A form the listbox I
    need user A's staff_ID recorded. If I changed my mind and selected
    user B, I would need user B's staff_ID recorded.

    Paul
     
    paulmitchell507, Aug 13, 2008
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.