Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: drop down help

  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    drop down help

    hey all, I need help with this, I am accessing a data base to fill in a drop down menu. I have managed to get my first drop down menu to do this, but now for the second box I need it to sellect another table from the data base.depending on the first choice. I have converted the record sets in to arrays but now i need the second menu to update it self before hitting the submit button. here is my code.


    ----------------------
    <% @ Language = VBScript %>
    <%Option Explicit%>
    <!--#include file="connection.asp"-->
    <!--#include virtual="adovbs.inc"-->
    <%
    Dim objRS
    Dim arr
    dim quad
    dim yard
    dim i
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    objRS.open "LabLoc", dcnDB, , ,adCmdTable
    arr = objRS.getrows()
    objRS.Close
    objRS.open "Quad", dcnDB, , ,adCmdTable
    quad = objrs.getrows()
    objRS.Close
    objRS.open "Yard", dcnDB, , ,adCmdTable
    yard = objrs.getrows()
    objRS.Close
    set objRS = nothing
    dcnDB.Close
    set dcnDB = nothing
    %>

    <HTML>
    <BODY>

    Multiple field search

    <form method =post action="mfsearch.asp">
    <!--search for computer location client side -->
    Computer Location:

    <select name="Location" size ="1" onChange="redirect(this.options.selectedIndex)">
    Response.Write "<option selected=""selected"" value="""">Choose....</option>"

    <%for i = 0 to ubound(arr,2)
    Response.Write "<option value="""">" &(arr(0,i))
    next
    Response.Write "</option>"
    %>
    </select>

    <select name="houseloc" size="1">
    response.write "<option selected=""selected"" value="""">choose from campus location first </option>"
    </select>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You need to post back the information to the server when the first element is changed. You either have to submit a form or add information to the query string. It is a lot easier with .NET

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    As A1ein51 said, you can change the onChange event in the first dropdown to handle a postback event and then using the info from the 1st selection to fill the 2nd dropdown

    Or

    You can use the information in these arrays to fill clientside javascript arrays. That way when the user selects one item the javascript automatically selects the proper array.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by miranda
    You can use the information in these arrays to fill clientside javascript arrays. That way when the user selects one item the javascript automatically selects the proper array.
    Use this Double combo javascript. Generate javascript arrays in the server-side.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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