ASP/Java

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

  1. I am not sure if this should be posted in a Java newsgroup or not, I
    am sure I will be told where it should be! I have a small
    asp(classic) app that runs the following java script to display a drop
    down list containing usernames from a access 2k database.

    <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

    This works, to the point where it puts the value of staff_ID into
    request.form("courses"). What I would like to do is store the
    "Group_ID" values also. Please could somebody provide the code to
    store the additional value. I then post the 2 values to a another asp
    page for insertion into another table in the database.

    Regards.
     
    paulmitchell507, Aug 7, 2008
    #1
    1. Advertising

  2. paulmitchell507

    Tim Slattery Guest

    paulmitchell507 <> wrote:

    >I am not sure if this should be posted in a Java newsgroup or not, I
    >am sure I will be told where it should be! I have a small
    >asp(classic) app that runs the following java script to display a drop
    >down list containing usernames from a access 2k database.
    >
    ><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
    >
    >This works, to the point where it puts the value of staff_ID into
    >request.form("courses"). What I would like to do is store the
    >"Group_ID" values also. Please could somebody provide the code to
    >store the additional value. I then post the 2 values to a another asp
    >page for insertion into another table in the database.


    Where to start? You're not using Java, you're using JavaScript, the
    two are completely different. And your question has nothing to do with
    that either.

    When you select an item from a listbox or dropdown box (both of which
    are <select...> groups and submit the form, the "value" string in the
    <option..> tag is sent to the browser. That's it ONE value.

    You can create that value string so that it has several parts divided
    by (for example) a semicolon. So your option tag might look something
    like this:

    <option value="staffid;groupid">something</option>

    Now when the form is submitted, you get that value ("courses", in your
    case), and parse it on the semicolon (see the VBScript "split"
    function
    [http://msdn.microsoft.com/en-us/library/0764e5w5(VS.85).aspx]). Now
    you have your two values.

    --
    Tim Slattery
    MS MVP(Shell/User)

    http://members.cox.net/slatteryt
     
    Tim Slattery, Aug 7, 2008
    #2
    1. Advertising

  3. "paulmitchell507" <> wrote in message
    news:...
    > I am not sure if this should be posted in a Java newsgroup or not, I
    > am sure I will be told where it should be! I have a small
    > asp(classic) app that runs the following java script to display a drop
    > down list containing usernames from a access 2k database.
    >
    > <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
    >
    > This works, to the point where it puts the value of staff_ID into
    > request.form("courses"). What I would like to do is store the
    > "Group_ID" values also. Please could somebody provide the code to
    > store the additional value. I then post the 2 values to a another asp
    > page for insertion into another table in the database.
    >


    Where is the Group_ID?

    Can't the second ASP page determine the Group_ID by query the DB with the
    Staff_ID it has?


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 7, 2008
    #3
  4. On Aug 7, 4:40 pm, "Anthony Jones" <> wrote:
    > "paulmitchell507" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > I am not sure if this should be posted in a Java newsgroup or not, I
    > > am sure I will be told where it should be!  I have a small
    > > asp(classic) app that runs the following java script to display a drop
    > > down list containing usernames from a access 2k database.

    >
    > > <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

    >
    > > This works, to the point where it puts the value of staff_ID into
    > > request.form("courses").  What I would like to do is store the
    > > "Group_ID" values also.  Please could somebody provide the code to
    > > store the additional value.  I then post the 2 values to a another asp
    > > page for insertion into another table in the database.

    >
    > Where is the Group_ID?
    >
    > Can't the second ASP page determine the Group_ID by query the DB with the
    > Staff_ID it has?
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
    >
    > - Show quoted text -


    Thank you very much for you input, as you can tell, I am newbie!
    In the end I used the second ASP page to determine the Group_ID using
    the Staff_ID.
     
    paulmitchell507, Aug 12, 2008
    #4
    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. Ben
    Replies:
    3
    Views:
    1,187
  2. Michael Kintner
    Replies:
    0
    Views:
    861
    Michael Kintner
    Nov 30, 2003
  3. Ilias Lazaridis
    Replies:
    0
    Views:
    593
    Ilias Lazaridis
    Feb 1, 2005
  4. manish sahu
    Replies:
    3
    Views:
    1,021
  5. Isaac
    Replies:
    0
    Views:
    385
    Isaac
    Jan 20, 2011
Loading...

Share This Page