www.webdeveloper.com
Results 1 to 2 of 2

Thread: Related Dynamic Dropdowns

  1. #1
    Join Date
    Jan 2003
    Location
    dc metro area
    Posts
    1

    Question Related Dynamic Dropdowns

    I need to create 2 dropdowns, with the 2nd dropdown dependent on the selection in the 1st. They both need to be loaded from database table fields. The dropdowns must be part of an ASP page. If I create a recordset of all fields when the page loads. Can I requery the same recordset with a key from the 1st dropdown selection and build/display the 2nd dropdown? Any code examples would be greatly appreciated.
    Javascript..VBscript..whatever works best.

  2. #2
    Join Date
    Dec 2002
    Posts
    213

    drop down box

    Hello
    I have the same requirement, but I get an error message on the second retrieval of data. the first one works beautifully. See if you can make the code work for your requirement, then let me know what I can do to make it work for me !
    My code is :
    Option Explicit
    <%
    Dim MyAudioCategories
    Dim cString
    Dim query

    Public Function GetCategories()
    Dim rsAudioCategories
    Set MyAudioCategories= Server.CreateObject("ADODB.Connection")
    cString = "driver={Microsoft Access Driver (*.mdb)};" & _
    "dbq=D:\My Webs in working\d.zignsenterprisesolutions\deeni\_private\desaudiolist.mdb"
    MyAudioCategories.Open cString

    Set rsAudioCategories = Server.CreateObject("ADODB.RecordSet")
    query = "SELECT CategoryName FROM Categories Order By CategoryID"
    rsAudioCategories.Open query, MyAudioCategories

    Do Until rsAudioCategories.EOF
    GetCategories = GetCategories & "<OPTION VALUE=""" _
    & rsAudioCategories("CategoryName") _
    & """>" & rsAudioCategories("CategoryName") & "</OPTION>"
    rsAudioCategories.MoveNext
    Loop
    rsAudioCategories.Close()
    Set rsAudioCategories = Nothing
    MyAudioCategories.Close()
    Set MyAudioCategories = Nothing
    End Function

    Public Function GetAudioListByCategory(CategoryName)
    Dim MyAudioList
    Dim rsAudioList
    Dim TempReturn
    Dim SqlQuery
    Set MyAudioList= Server.CreateObject("ADODB.Connection")
    'cString = "driver={Microsoft Access Driver (*.mdb)};" & _
    ' "dbq=file\desaudiolist.mdb"
    MyAudioList.Open cString

    Set rsAudioList = Server.CreateObject("ADODB.RecordSet")

    SqlQuery = "SELECT Audiolist.[Track Number], Audiolist.[Track Description], Audiolist.[Track Time], Categories.CategoryName " & _
    "FROM Categories INNER JOIN AudioList " & _
    "ON Categories.CategoryID = AudioList.CategoryID " & _
    "WHERE (Categories.CategoryName = " & CategoryName & ") " & _
    "ORDER BY Categories.CategoryName, Audiolist.[Track Description] "

    rsAudioList.Open SqlQuery, MyAudioList

    TempReturn = "<table border=1 cellspacing=1 style=border-collapse: collapse bordercolor=#111111 width=687>" _
    & "<tr><td width=119>Track Number</td>" _
    & "<td width=456>Track Description</td>" _
    & "<td width=98>Track Time</td></tr>" & vbNewLine

    Do Until rsAudioList.EOF
    TempReturn = TempReturn & "<TR>" _
    & "<td width=119>" _
    & rsAudioList("Track Number") & "</td>" _
    & "<td width=456>" _
    & rsAudioList("Track Description") & "</td>" _
    & "<td width=98>" _
    & rsAudioList("Track Time") & "</td></tr>" & vbNewLine

    rsAudioList.MoveNext
    Loop
    TempReturn = TempReturn & "</Table>" & vbNewLine
    GetAuctionItemsByCategory = TempReturn

    rsAudioList.Close()
    Set rsAudioList = Nothing
    MyAudioList.Close()
    Set MyAudioList = Nothing
    End Function



    %>

    Note : this is my script file to use with my asp file.
    the error comes on line :
    rsAudioList.Open SqlQuery, MyAudioList

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles