Combo box on ASP page

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

  1. I am not sure if this should be posted in a Java forum, bit it does
    concern asp.
    I have the following script on my asp (classic) page.

    <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
    The script works fine, it lists the firstlastname field from the
    access 2k database and places the corrasponding staff_ID value in
    Request.Form("courses"). What I would like to do is display the
    selected firstlastname value in box further down the page.
    I would appreciate it if anybody could help with, what looks like, a
    simple task.
     
    paulmitchell507, Aug 8, 2008
    #1
    1. Advertising

  2. "paulmitchell507" <> wrote in message
    news:...
    > I am not sure if this should be posted in a Java forum, bit it does
    > concern asp.
    > I have the following script on my asp (classic) page.
    >
    > <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
    > The script works fine, it lists the firstlastname field from the
    > access 2k database and places the corrasponding staff_ID value in
    > Request.Form("courses"). What I would like to do is display the
    > selected firstlastname value in box further down the page.
    > I would appreciate it if anybody could help with, what looks like, a
    > simple task.


    Before being able t answer that we need to know why on selected an entry in
    the combo you submit the form?


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 8, 2008
    #2
    1. Advertising

  3. On Aug 8, 10:23 am, "Anthony Jones" <> wrote:
    > "paulmitchell507" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > I am not sure if this should be posted in a Java forum, bit it does
    > > concern asp.
    > > I have the following script on my asp (classic) page.

    >
    > > <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
    > > The script works fine, it lists the firstlastname field from the
    > > access 2k database and places the corrasponding staff_ID value in
    > > Request.Form("courses").  What I would like to do is display the
    > > selected firstlastname value in box further down the page.
    > > I would appreciate it if anybody could help with, what looks like, a
    > > simple task.

    >
    > Before being able t answer that we need to know why on selected an entry in
    > the combo you submit the form?
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
    >
    > - Show quoted text -


    I am not sure I fully understand the question (I am what you call a
    newbie). Please find attched the rest of the code on my asp page.

    </SELECT>
    </form>
    <html>
    <head>
    <title>Form to Database</title>
    </head>
    <body>
    <!-- comment - start the HTML form and use a HTML table for
    formatting-->
    <form name="form1" action="add_to_database.asp" method="post">
    <div align="center">
    <table width="80%" border="0">
    <tr>
    <td>group_id :</td>
    <td><input type="text" name="Name" value=""></td>
    </tr>
    <tr>
    <td>StartDate :</td>
    <td><input type="text" name="StartDate"></td>
    </tr>
    <tr>
    <td>EndDate :</td>
    <td><input type="text" name="EndDate"></td>
    </tr>
    <tr>
    <td>If requesting a half day, will you be absent A.M. or P.M.?</td>
    <td>NA<input type="radio" name="ampm" value=""/>
    AM<input type="radio" name="ampm" value="AM"/>PM<input type="radio"
    name="ampm" value="PM"></td>
    </tr>
    <tr>
    <td>Number of Working days :</td>
    <td><input type="number" name="Numberofdays"></td>
    </tr>
    <tr>
    <td><input type="HIDDEN" name="courses" value="<
    %=request.form("courses")%>"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="submit details" name="submit"></td>
    </tr>
    </table>
    </div>
    </form>
    <!-- end the HTML form-->
    </body>
    </html>
     
    paulmitchell507, Aug 8, 2008
    #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.
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:
    649
    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:
    179
  5. SM
    Replies:
    2
    Views:
    401
Loading...

Share This Page