Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 August 18th, 2004, 03:33 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default function for dropdown with 3 checkboxes

Within my HTML I have inserted a dropdown list and transfered three checkboxes from elsewhere in the page to under the column (the checkboxes enable/disable the dropdown). Within the ASP page (see below) I have the three checkoxes listed (I don't know if the function has to change or if it's correct). What is the code which would include the dropdown list selection? I have the three checkbox responses in bold.

Code:
' This function will display the results of the search
Private Sub ShowResults()
    Dim strConn     ' Database connection string
    Dim SQL         ' String that will have our SQL statments
    Dim RS          ' Recordset object
    Dim Keyword     ' Keyword for search
    Dim nRecCount   ' Number of records found
    Dim nPageCount  ' Number of pages of records we have
    Dim nPage       ' Current page number
    Dim iCounter    'for the checkboxes
    Dim iLoopCount
    Dim aRecTypes

    ' Let's see what page are we looking at right now
    nPage = CLng(Request.QueryString("Page"))

    ' Let's see what user wants to search for today :)
    Keyword = Trim(Request.QueryString("Keyword"))

    ' define our SQL statment
    ' we will be looking for all the records in tblItem table 
    ' where ItemName contains our Keyword
    ' do not forget to fix tick marks (single quotes) in our Keyword
    SQL = "SELECT * FROM bible WHERE "

    ' Create our connection string
    strConn = GetConnectionString()
             Response.Write request.QueryString("book")
    If   request.QueryString("book")="Book" then

      Sql = Sql & "book LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if

    If   request.QueryString("book_spoke")="Book_Spoke" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "book_spoke LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if
    If   request.QueryString("book_title")="Book_Title" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "book_title LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if

    If   request.QueryString("chapter")="Chapter" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "chapter LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if


    If   request.QueryString("chapter_spoke")="Chapter_Spoke" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "chapter_spoke LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if
    If   request.QueryString("verse")="Verse" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "verse LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if

   If   request.QueryString("verse_spoke")="Verse_Spoke" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "verse_spoke LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if

    If   request.QueryString("text_data")="Text" then

      If iCounter > 0 Then
        Sql = Sql & " AND "
      End If

      Sql = Sql & "text_data LIKE '%" & Keyword & "%'"

      iCounter = iCounter + 1

    end if

     If Trim(Request.QueryString("recordType")) <> "" Then

  aRecTypes = Split(Request.QueryString("recordType"), ",")

  If IsArray(aRecTypes) Then 'This is a bit redundant, but it can't hurt
    SQL = SQL & " AND ("



    For iLoopCount = 0 To UBound(aRecTypes)
      If iLoopCount <> 0 Then
        SQL = SQL & " OR "
      End If

      SQL = SQL & " recordType = '" & trim(aRecTypes(iLoopCount)) & "'"
    Next
  End If
  SQL = SQL & ")"
End If





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to integrate search function n dropdown box jun9nah ASP.NET 1.0 and 1.1 Basics 1 July 25th, 2006 06:51 AM
How to integrate search function n a dropdown box jun9nah VB.NET 0 July 24th, 2006 10:12 PM





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