Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 31st, 2003, 01:13 PM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tcasp
Default Search using drop down list box and a text box

I am trying to search database using drop down list box and a text box from two database tables with a submit button
table1= MainCategories like technology,internet with ids 10,20 and etc.
table2=subCategories like category=technology,title=web developer,id=10
again same but tile is programmer and id is 10 and etc
u will select category from database driven list box and u will enter key word like web developer
as a result it should display all matching records from the two tables but I have prob it displays every record ,so I need help.
Thank you .
When I try with inner join it shows all the records
when I use "&id&" ,it gives me an error message "object required"
I am not sure where I am making mistake ?

Here is code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Drop Down List box</title>


<script language="javascript">

    function go()
        {


         if(document.frm1.s1.options[document.frm1.s1.selectedIndex].value=="ww" )
        

             {
            
                 alert("You did not make any selection,enter search key word,so try again?");
                return false;

             }
            
                 if (frm1.title.value == "")//if text box is empty
                 {
                     alert("You did not ,enter search key word,so try again?");
                     document.frm1.title.focus();
                 return false();

                 }
         else
                document.frm1.catid.value=
                document.frm1.s1.options[document.frm1.s1.selectedIndex].value

             document.frm1.submit();
                return true;
     }
    
    

</script>

</head>

<body>
<%
            
         Dim Conn,RS,sSQL,catid,category,title
    

         Set Conn = Server.createobject("Adodb.connection")
         Set RS = Server.CreateObject ("ADODB.Recordset")
        ' Conn.Open ("DSN=test")
         Conn.Open ("DSN=tariqch;UID=administrator;PWD=admin") 'for sql Server database
         sSQL = " Select catid,category from tblcategory "
         Set RS = Conn.execute(sSQL)

    %>

    <center>

    <form name ="frm1" action="test1.asp" method="post">


     <table height="20%" width="20">
         <Input type="hidden" Name="catid" Value="<%=rs("catid")%>">

            <tr>
             <td>
            <Select Name="s1">

                <option value="ww" Selected>---Make a Selection----</option>
    
                    <%Do While Not rs.EOF %>
    
                         <option Value="<%=rs("catid")%>"><%=rs("category")%>

                        
             <%
                     rs.moveNext
                        Loop
                     rs.close
                    Set rs =nothing
                 %>
    
                 </Select></td>
             </tr>
             <tr>
                     <td>
                         <Input type="text" Name="title" size="15"></td>
                    </tr>
             <tr> <td>
                <input type="button" Value=" Search " Name="btnsub" onClick="go();">
                <input type="reset" Value=" Clear " Name="Reset">
                </td>
                 </tr>
         </table>
    </form>
</center>

</body>
</html>

%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY background="bg.jpg">

<%
    
    catid= Request.form("catid")

    category= Request.Form("category")
    
     title=Request.Form("title")
     description =Request.Form("description")
    
     Dim conn,sSQL,Rs,catid,subcatid

    Set conn = Server.createobject("AdoDB.connection")
    Set RS = Server.CreateObject ("ADODB.Recordset")
    Conn.Open ("DSN=test;UID=administrator;PWD=admin")

     'Conn.open ("DSN=tariqch")
    

    

sSQL ="Select tblcategory.category,tblsubcat.title,tblsubcat.des cription from tblcategory,tblsubcat Where tblcategory.catid = "&tblsubcat.catid&" "
            
        
    Set RS = conn.execute(sSQL)

%>

    <center><table border="4" cellspacing=2 cellpadding=2>
                
                    <tr bgcolor="yellow">
                        <td><b>Category</b></td>
                        <td><b>title</b></td>
                        <td><b>Description</b></td>

                    </tr>

<% While NOT rs.EOF %>

                    <tr>
                        <td> <%=rs("category") %></td>
                        <td> <%=rs("title") %></td>
                        <td> <%=rs("Description") %></td>
                            
                    </tr>


     <%
                rs.MoveNext
            Wend
    
        rs.close
        conn.Close
        Set rs = Nothing
        Set conn = Nothing
    
     %>

    
            </table>
             </Center>
</BODY>
</HTML>
 
Old July 31st, 2003, 02:58 PM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tcasp
Default

I have solved this prob by myself.

Thank you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.