Display User Selection From Combo Box

Discussion in 'ASP General' started by rikesh, Feb 6, 2004.

  1. rikesh

    rikesh Guest

    Hi

    I'm sure this is a very trivial problem!
    I have a combo bound to a recordset. I was wondering how I can show the
    value on the page, what the user has selected?
    The code that I'm using is below.
    Any help, would be much apprceciated.

    Kind regards

    --
    Kind Regards

    Rikesh
    (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)



    <%

    Dim objConnection 'The connection object
    Dim objRecordset 'The recordset object

    ' create the Connection object
    Set objConnection = Server.CreateObject("ADODB.Connection")
    ' open the DSN
    objConnection.Open "Provider=sqloledb;" & _
    "Data Source=DEVSVR;" & _
    "Initial Catalog=pubs;" & _
    "User Id=sa;" & _
    "Password=admin"

    ' creates the recordset object
    Set objRecordset = Server.CreateObject("ADODB.Recordset")

    ' SQL String for query
    Dim strSQL
    strSQL = "SELECT au_id, au_lname FROM Authors"

    ' execute the SQL statement that you want
    ' The query should return all the data you'll
    ' need in your combo box
    objRecordset.Open strSQL, objConnection

    Request.Form("au_lname")
    Response.Write (Request.Form("au_lname"))

    %>
    <HTML>
    <BODY>
    <FORM ACTION="DBCombo.asp" METHOD=POST>
    <select name=cboPrimary size=1 >
    <!--onChange="frmTest.submit();"> -->
    Choose from the combo:
    select name="lstTopic" size="1">
    <%
    ' while we don't get the end of DataBase
    Do While Not objRecordset.EOF
    'we put the ID at Value
    'this value is important to linked tables
    %>
    <option VALUE="<%=objRecordset("au_ID")%>">
    <!-- This is what will appear in the combo box -->
    <%=objRecordset("au_lname")%>
    </option>
    <%
    ' Move to the next record...
    objRecordset.MoveNext
    Loop ' keep the loop
    %>
    </SELECT>
    </FORM>
    </BODY>
    </HTML>
    <%
    ' close the recordset object
    objRecordset.Close

    ' clean the Recordset object
    Set objRecordset = Nothing
    %>
    rikesh, Feb 6, 2004
    #1
    1. Advertising

  2. rikesh

    Alex Goodey Guest

    Do you want to the selection to be displayed on the same page as the form?
    or after the fgorm has been submitted?

    if it's the first then it is a client side issue and you will have a better
    response from a client side or javascript newsgroup


    "rikesh" <> wrote in message
    news:...
    > Hi
    >
    > I'm sure this is a very trivial problem!
    > I have a combo bound to a recordset. I was wondering how I can show the
    > value on the page, what the user has selected?
    > The code that I'm using is below.
    > Any help, would be much apprceciated.
    >
    > Kind regards
    >
    > --
    > Kind Regards
    >
    > Rikesh
    > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    >
    >
    >
    > <%
    >
    > Dim objConnection 'The connection object
    > Dim objRecordset 'The recordset object
    >
    > ' create the Connection object
    > Set objConnection = Server.CreateObject("ADODB.Connection")
    > ' open the DSN
    > objConnection.Open "Provider=sqloledb;" & _
    > "Data Source=DEVSVR;" & _
    > "Initial Catalog=pubs;" & _
    > "User Id=sa;" & _
    > "Password=admin"
    >
    > ' creates the recordset object
    > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    >
    > ' SQL String for query
    > Dim strSQL
    > strSQL = "SELECT au_id, au_lname FROM Authors"
    >
    > ' execute the SQL statement that you want
    > ' The query should return all the data you'll
    > ' need in your combo box
    > objRecordset.Open strSQL, objConnection
    >
    > Request.Form("au_lname")
    > Response.Write (Request.Form("au_lname"))
    >
    > %>
    > <HTML>
    > <BODY>
    > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > <select name=cboPrimary size=1 >
    > <!--onChange="frmTest.submit();"> -->
    > Choose from the combo:
    > select name="lstTopic" size="1">
    > <%
    > ' while we don't get the end of DataBase
    > Do While Not objRecordset.EOF
    > 'we put the ID at Value
    > 'this value is important to linked tables
    > %>
    > <option VALUE="<%=objRecordset("au_ID")%>">
    > <!-- This is what will appear in the combo box -->
    > <%=objRecordset("au_lname")%>
    > </option>
    > <%
    > ' Move to the next record...
    > objRecordset.MoveNext
    > Loop ' keep the loop
    > %>
    > </SELECT>
    > </FORM>
    > </BODY>
    > </HTML>
    > <%
    > ' close the recordset object
    > objRecordset.Close
    >
    > ' clean the Recordset object
    > Set objRecordset = Nothing
    > %>
    >
    >
    >
    Alex Goodey, Feb 6, 2004
    #2
    1. Advertising

  3. rikesh

    rikesh Guest

    Yeah, I would prefer on the same page!
    So does that it's a client issue?

    "Alex Goodey" <> wrote in message
    news:bvvp7o$1143cs$-berlin.de...
    > Do you want to the selection to be displayed on the same page as the form?
    > or after the fgorm has been submitted?
    >
    > if it's the first then it is a client side issue and you will have a

    better
    > response from a client side or javascript newsgroup
    >
    >
    > "rikesh" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I'm sure this is a very trivial problem!
    > > I have a combo bound to a recordset. I was wondering how I can show the
    > > value on the page, what the user has selected?
    > > The code that I'm using is below.
    > > Any help, would be much apprceciated.
    > >
    > > Kind regards
    > >
    > > --
    > > Kind Regards
    > >
    > > Rikesh
    > > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    > >
    > >
    > >
    > > <%
    > >
    > > Dim objConnection 'The connection object
    > > Dim objRecordset 'The recordset object
    > >
    > > ' create the Connection object
    > > Set objConnection = Server.CreateObject("ADODB.Connection")
    > > ' open the DSN
    > > objConnection.Open "Provider=sqloledb;" & _
    > > "Data Source=DEVSVR;" & _
    > > "Initial Catalog=pubs;" & _
    > > "User Id=sa;" & _
    > > "Password=admin"
    > >
    > > ' creates the recordset object
    > > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    > >
    > > ' SQL String for query
    > > Dim strSQL
    > > strSQL = "SELECT au_id, au_lname FROM Authors"
    > >
    > > ' execute the SQL statement that you want
    > > ' The query should return all the data you'll
    > > ' need in your combo box
    > > objRecordset.Open strSQL, objConnection
    > >
    > > Request.Form("au_lname")
    > > Response.Write (Request.Form("au_lname"))
    > >
    > > %>
    > > <HTML>
    > > <BODY>
    > > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > > <select name=cboPrimary size=1 >
    > > <!--onChange="frmTest.submit();"> -->
    > > Choose from the combo:
    > > select name="lstTopic" size="1">
    > > <%
    > > ' while we don't get the end of DataBase
    > > Do While Not objRecordset.EOF
    > > 'we put the ID at Value
    > > 'this value is important to linked tables
    > > %>
    > > <option VALUE="<%=objRecordset("au_ID")%>">
    > > <!-- This is what will appear in the combo box -->
    > > <%=objRecordset("au_lname")%>
    > > </option>
    > > <%
    > > ' Move to the next record...
    > > objRecordset.MoveNext
    > > Loop ' keep the loop
    > > %>
    > > </SELECT>
    > > </FORM>
    > > </BODY>
    > > </HTML>
    > > <%
    > > ' close the recordset object
    > > objRecordset.Close
    > >
    > > ' clean the Recordset object
    > > Set objRecordset = Nothing
    > > %>
    > >
    > >
    > >

    >
    >
    rikesh, Feb 6, 2004
    #3
  4. rikesh

    Alex Goodey Guest

    yep, do a search on google and you will probably find what you are looking
    for.

    it will be something to do with the onChange event of the drop down, or
    something like that

    "rikesh" <> wrote in message
    news:u$...
    > Yeah, I would prefer on the same page!
    > So does that it's a client issue?
    >
    > "Alex Goodey" <> wrote in message
    > news:bvvp7o$1143cs$-berlin.de...
    > > Do you want to the selection to be displayed on the same page as the

    form?
    > > or after the fgorm has been submitted?
    > >
    > > if it's the first then it is a client side issue and you will have a

    > better
    > > response from a client side or javascript newsgroup
    > >
    > >
    > > "rikesh" <> wrote in message
    > > news:...
    > > > Hi
    > > >
    > > > I'm sure this is a very trivial problem!
    > > > I have a combo bound to a recordset. I was wondering how I can show

    the
    > > > value on the page, what the user has selected?
    > > > The code that I'm using is below.
    > > > Any help, would be much apprceciated.
    > > >
    > > > Kind regards
    > > >
    > > > --
    > > > Kind Regards
    > > >
    > > > Rikesh
    > > > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    > > >
    > > >
    > > >
    > > > <%
    > > >
    > > > Dim objConnection 'The connection object
    > > > Dim objRecordset 'The recordset object
    > > >
    > > > ' create the Connection object
    > > > Set objConnection = Server.CreateObject("ADODB.Connection")
    > > > ' open the DSN
    > > > objConnection.Open "Provider=sqloledb;" & _
    > > > "Data Source=DEVSVR;" & _
    > > > "Initial Catalog=pubs;" & _
    > > > "User Id=sa;" & _
    > > > "Password=admin"
    > > >
    > > > ' creates the recordset object
    > > > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    > > >
    > > > ' SQL String for query
    > > > Dim strSQL
    > > > strSQL = "SELECT au_id, au_lname FROM Authors"
    > > >
    > > > ' execute the SQL statement that you want
    > > > ' The query should return all the data you'll
    > > > ' need in your combo box
    > > > objRecordset.Open strSQL, objConnection
    > > >
    > > > Request.Form("au_lname")
    > > > Response.Write (Request.Form("au_lname"))
    > > >
    > > > %>
    > > > <HTML>
    > > > <BODY>
    > > > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > > > <select name=cboPrimary size=1 >
    > > > <!--onChange="frmTest.submit();"> -->
    > > > Choose from the combo:
    > > > select name="lstTopic" size="1">
    > > > <%
    > > > ' while we don't get the end of DataBase
    > > > Do While Not objRecordset.EOF
    > > > 'we put the ID at Value
    > > > 'this value is important to linked tables
    > > > %>
    > > > <option VALUE="<%=objRecordset("au_ID")%>">
    > > > <!-- This is what will appear in the combo box -->
    > > > <%=objRecordset("au_lname")%>
    > > > </option>
    > > > <%
    > > > ' Move to the next record...
    > > > objRecordset.MoveNext
    > > > Loop ' keep the loop
    > > > %>
    > > > </SELECT>
    > > > </FORM>
    > > > </BODY>
    > > > </HTML>
    > > > <%
    > > > ' close the recordset object
    > > > objRecordset.Close
    > > >
    > > > ' clean the Recordset object
    > > > Set objRecordset = Nothing
    > > > %>
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Alex Goodey, Feb 6, 2004
    #4
  5. rikesh

    ±Ç¹Î¼ö Guest

    "rikesh" <> wrote in message
    news:...
    > Hi
    >
    > I'm sure this is a very trivial problem!
    > I have a combo bound to a recordset. I was wondering how I can show the
    > value on the page, what the user has selected?
    > The code that I'm using is below.
    > Any help, would be much apprceciated.
    >
    > Kind regards
    >
    > --
    > Kind Regards
    >
    > Rikesh
    > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    >
    >
    >
    > <%
    >
    > Dim objConnection 'The connection object
    > Dim objRecordset 'The recordset object
    >
    > ' create the Connection object
    > Set objConnection = Server.CreateObject("ADODB.Connection")
    > ' open the DSN
    > objConnection.Open "Provider=sqloledb;" & _
    > "Data Source=DEVSVR;" & _
    > "Initial Catalog=pubs;" & _
    > "User Id=sa;" & _
    > "Password=admin"
    >
    > ' creates the recordset object
    > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    >
    > ' SQL String for query
    > Dim strSQL
    > strSQL = "SELECT au_id, au_lname FROM Authors"
    >
    > ' execute the SQL statement that you want
    > ' The query should return all the data you'll
    > ' need in your combo box
    > objRecordset.Open strSQL, objConnection
    >
    > Request.Form("au_lname")
    > Response.Write (Request.Form("au_lname"))
    >
    > %>
    > <HTML>
    > <BODY>
    > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > <select name=cboPrimary size=1 >
    > <!--onChange="frmTest.submit();"> -->
    > Choose from the combo:
    > select name="lstTopic" size="1">
    > <%
    > ' while we don't get the end of DataBase
    > Do While Not objRecordset.EOF
    > 'we put the ID at Value
    > 'this value is important to linked tables
    > %>
    > <option VALUE="<%=objRecordset("au_ID")%>">
    > <!-- This is what will appear in the combo box -->
    > <%=objRecordset("au_lname")%>
    > </option>
    > <%
    > ' Move to the next record...
    > objRecordset.MoveNext
    > Loop ' keep the loop
    > %>
    > </SELECT>
    > </FORM>
    > </BODY>
    > </HTML>
    > <%
    > ' close the recordset object
    > objRecordset.Close
    >
    > ' clean the Recordset object
    > Set objRecordset = Nothing
    > %>
    >



    <script language="javascript">
    <!--
    function ChangeSelect(which)
    {
    var wOne = which

    document.sel.chgsel.value = wOne;
    }
    //-->
    </script>
    </HEAD>

    <form name="sel">
    <select name="lect" OnChange="ChangeSelect(this.value);">
    <option value="111">111</option>
    <option value="222">222</option>
    <option value="333">333</option>
    <option value="444">444</option>
    <option value="555">555</option>
    </select>
    <br><br>
    <input type="text" name="chgsel" size="20">
    </form>


    MSN :
    email :
    http://www.ubizcom.co.kr
    ---------------------------------------------- From DevSonner
    ±Ç¹Î¼ö, Feb 6, 2004
    #5
  6. rikesh

    rikesh Guest

    Cheers that works really well, by the way, a quick question, can one use
    javascript and VBScript on the same page???


    "±Ç¹Î¼ö" <> wrote in message
    news:c003pl$st1$...
    >
    > "rikesh" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I'm sure this is a very trivial problem!
    > > I have a combo bound to a recordset. I was wondering how I can show the
    > > value on the page, what the user has selected?
    > > The code that I'm using is below.
    > > Any help, would be much apprceciated.
    > >
    > > Kind regards
    > >
    > > --
    > > Kind Regards
    > >
    > > Rikesh
    > > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    > >
    > >
    > >
    > > <%
    > >
    > > Dim objConnection 'The connection object
    > > Dim objRecordset 'The recordset object
    > >
    > > ' create the Connection object
    > > Set objConnection = Server.CreateObject("ADODB.Connection")
    > > ' open the DSN
    > > objConnection.Open "Provider=sqloledb;" & _
    > > "Data Source=DEVSVR;" & _
    > > "Initial Catalog=pubs;" & _
    > > "User Id=sa;" & _
    > > "Password=admin"
    > >
    > > ' creates the recordset object
    > > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    > >
    > > ' SQL String for query
    > > Dim strSQL
    > > strSQL = "SELECT au_id, au_lname FROM Authors"
    > >
    > > ' execute the SQL statement that you want
    > > ' The query should return all the data you'll
    > > ' need in your combo box
    > > objRecordset.Open strSQL, objConnection
    > >
    > > Request.Form("au_lname")
    > > Response.Write (Request.Form("au_lname"))
    > >
    > > %>
    > > <HTML>
    > > <BODY>
    > > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > > <select name=cboPrimary size=1 >
    > > <!--onChange="frmTest.submit();"> -->
    > > Choose from the combo:
    > > select name="lstTopic" size="1">
    > > <%
    > > ' while we don't get the end of DataBase
    > > Do While Not objRecordset.EOF
    > > 'we put the ID at Value
    > > 'this value is important to linked tables
    > > %>
    > > <option VALUE="<%=objRecordset("au_ID")%>">
    > > <!-- This is what will appear in the combo box -->
    > > <%=objRecordset("au_lname")%>
    > > </option>
    > > <%
    > > ' Move to the next record...
    > > objRecordset.MoveNext
    > > Loop ' keep the loop
    > > %>
    > > </SELECT>
    > > </FORM>
    > > </BODY>
    > > </HTML>
    > > <%
    > > ' close the recordset object
    > > objRecordset.Close
    > >
    > > ' clean the Recordset object
    > > Set objRecordset = Nothing
    > > %>
    > >

    >
    >
    > <script language="javascript">
    > <!--
    > function ChangeSelect(which)
    > {
    > var wOne = which
    >
    > document.sel.chgsel.value = wOne;
    > }
    > //-->
    > </script>
    > </HEAD>
    >
    > <form name="sel">
    > <select name="lect" OnChange="ChangeSelect(this.value);">
    > <option value="111">111</option>
    > <option value="222">222</option>
    > <option value="333">333</option>
    > <option value="444">444</option>
    > <option value="555">555</option>
    > </select>
    > <br><br>
    > <input type="text" name="chgsel" size="20">
    > </form>
    >
    >
    > MSN :
    > email :
    > http://www.ubizcom.co.kr
    > ---------------------------------------------- From DevSonner
    >
    rikesh, Feb 6, 2004
    #6
  7. rikesh

    DevSonner Guest

    <script language="javascript">

    <script language="vbscript">
    ??


    "rikesh" <> wrote in message
    news:...
    > Cheers that works really well, by the way, a quick question, can one use
    > javascript and VBScript on the same page???
    >
    >
    > "±Ç¹Î¼ö" <> wrote in message
    > news:c003pl$st1$...
    > >
    > > "rikesh" <> wrote in message
    > > news:...
    > > > Hi
    > > >
    > > > I'm sure this is a very trivial problem!
    > > > I have a combo bound to a recordset. I was wondering how I can show

    the
    > > > value on the page, what the user has selected?
    > > > The code that I'm using is below.
    > > > Any help, would be much apprceciated.
    > > >
    > > > Kind regards
    > > >
    > > > --
    > > > Kind Regards
    > > >
    > > > Rikesh
    > > > (V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)
    > > >
    > > >
    > > >
    > > > <%
    > > >
    > > > Dim objConnection 'The connection object
    > > > Dim objRecordset 'The recordset object
    > > >
    > > > ' create the Connection object
    > > > Set objConnection = Server.CreateObject("ADODB.Connection")
    > > > ' open the DSN
    > > > objConnection.Open "Provider=sqloledb;" & _
    > > > "Data Source=DEVSVR;" & _
    > > > "Initial Catalog=pubs;" & _
    > > > "User Id=sa;" & _
    > > > "Password=admin"
    > > >
    > > > ' creates the recordset object
    > > > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    > > >
    > > > ' SQL String for query
    > > > Dim strSQL
    > > > strSQL = "SELECT au_id, au_lname FROM Authors"
    > > >
    > > > ' execute the SQL statement that you want
    > > > ' The query should return all the data you'll
    > > > ' need in your combo box
    > > > objRecordset.Open strSQL, objConnection
    > > >
    > > > Request.Form("au_lname")
    > > > Response.Write (Request.Form("au_lname"))
    > > >
    > > > %>
    > > > <HTML>
    > > > <BODY>
    > > > <FORM ACTION="DBCombo.asp" METHOD=POST>
    > > > <select name=cboPrimary size=1 >
    > > > <!--onChange="frmTest.submit();"> -->
    > > > Choose from the combo:
    > > > select name="lstTopic" size="1">
    > > > <%
    > > > ' while we don't get the end of DataBase
    > > > Do While Not objRecordset.EOF
    > > > 'we put the ID at Value
    > > > 'this value is important to linked tables
    > > > %>
    > > > <option VALUE="<%=objRecordset("au_ID")%>">
    > > > <!-- This is what will appear in the combo box -->
    > > > <%=objRecordset("au_lname")%>
    > > > </option>
    > > > <%
    > > > ' Move to the next record...
    > > > objRecordset.MoveNext
    > > > Loop ' keep the loop
    > > > %>
    > > > </SELECT>
    > > > </FORM>
    > > > </BODY>
    > > > </HTML>
    > > > <%
    > > > ' close the recordset object
    > > > objRecordset.Close
    > > >
    > > > ' clean the Recordset object
    > > > Set objRecordset = Nothing
    > > > %>
    > > >

    > >
    > >
    > > <script language="javascript">
    > > <!--
    > > function ChangeSelect(which)
    > > {
    > > var wOne = which
    > >
    > > document.sel.chgsel.value = wOne;
    > > }
    > > //-->
    > > </script>
    > > </HEAD>
    > >
    > > <form name="sel">
    > > <select name="lect" OnChange="ChangeSelect(this.value);">
    > > <option value="111">111</option>
    > > <option value="222">222</option>
    > > <option value="333">333</option>
    > > <option value="444">444</option>
    > > <option value="555">555</option>
    > > </select>
    > > <br><br>
    > > <input type="text" name="chgsel" size="20">
    > > </form>
    > >
    > >
    > > MSN :
    > > email :
    > > http://www.ubizcom.co.kr
    > > ---------------------------------------------- From DevSonner
    > >

    >
    >
    DevSonner, Feb 6, 2004
    #7
  8. rikesh

    middletree Guest

    hate to soudn like one of those people who always corrects others, but it's
    not a combo. Call it a select, or a dropdown, or whatever you want. But
    there is no such thing as a combo on web products.
    middletree, Feb 6, 2004
    #8
  9. rikesh

    rikesh Guest

    I'll bear that in mind in the future!!! Cheers! ;-)

    "middletree" <> wrote in message
    news:%...
    > hate to soudn like one of those people who always corrects others, but

    it's
    > not a combo. Call it a select, or a dropdown, or whatever you want. But
    > there is no such thing as a combo on web products.
    >
    >
    rikesh, Feb 9, 2004
    #9
    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:
    601
    Ken Cox [Microsoft MVP]
    Jun 29, 2004
  2. Jacques Chaurette

    combo box selection problem

    Jacques Chaurette, May 31, 2005, in forum: Java
    Replies:
    0
    Views:
    404
    Jacques Chaurette
    May 31, 2005
  3. Adrian
    Replies:
    1
    Views:
    207
    Bullschmidt
    Feb 18, 2004
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    570
    Bob Barrows [MVP]
    Nov 16, 2005
  5. SM
    Replies:
    2
    Views:
    356
Loading...

Share This Page