Using Pull Down menu to Populate the page from DB

  • Hi guys,

    does anyone know how to populate the page's text boxes and pull down menus using an initial pull down menu at the top without using a button? Is there any such way? Or do I really have to use the button thing? Right now, I have one that uses a button after the first pull down menu field which populates the data in the rest of the fields if the user clicks on the button.

    Otherwise, is there any way to disable the text fields and buttons if the initial button is not clicked?


  • I think we need more info. VB? ASP? what language? Is there a SQL issue involved?


  • Have you looked into the onchange? I'm not too experienced with scripting in web pages, but I recall having done something along these lines a few years back. Here's a link, has to do with MS-centric development and it's flavor of design-time controls:

  • are both good places to start for asp and db pulldown navigation.

  • Hi guys,

    i'm working in ASP in a Microsoft SQL Server environment. I dunno whether the Onchange event works in ASP but i do know that it works in VB.


  • Yes there is an onChange event in java Script. Just add the event handler to the tag. <SELECT name="dropDown" onChange="dropDownChanged()"> Then add the function dropDownChanged() in a <Script> section.

  • Yah I have found out about it already. Thnx dude. 🙂 But I have another question here : I am using Commandtext as the SQL statement. Is it possible to execute it like this:

    Set rsbanner = newscmd.Execute ??

    I have tried it but found that they are asking for the initialisation of my newscmd which i have initialised in a seperate include file.

    my code looks something like this:


    Sub BannerType_onChange()

    counter = AddBanner.BannerType.SelectedIndex

    If counter = 1 Then

    loc = "Top"


    If counter = 2 Then

    loc = "Side"


    loc = ""

    End If

    End If

    If loc <> "" Then

    If loc = "Top" Then

    newscmd.CommandText = "Select * From Banner_Top"


    If loc = "Side" Then

    newscmd.CommandText = "Select * From Banner_Side"

    End If

    End If

    Set rsBanner = newscmd.Execute

    If not rsBanner.EOF or rsBanner.BOF Then

    countban = 0


    Do While not rsBanner.EOF

    countban = countban + 1



    End If

    End If

    AddBanner.ID_Num.Value = countban

    End Sub


    Above is my function coding....Any idea why it is not working?

  • Your sub is client side script is your include file initializing the connection object client side also? or is it maybe initializing it server side?

  • I dun really know whether it is on the server end or client side. My connection to db is all done in an include file which i call from all the seperate scripts.

    Script looks something like this :

    set rsConn = Server.CreateObject("ADODB.Connection")

    rsConn.Open SQLdb

    set newscmd = Server.CreateObject("ADODB.Command")

    set newscmd.activeconnection = rsConn



  • Thats your problem. The connection is Server side and your <SCRIPT> is client side. They do not know about each other. Notice your code uses Server.CreateObject


    The CreateObject method creates an instance of a server component. If the component has implemented the OnStartPage and OnEndPage methods, the OnStartPage method is called at this time. For more information about server components, see Installable Components for ASP.


    Server.CreateObject( progID )



    Specifies the type of object to create. The format for progID is [Vendor.]Component[.Version].


    By default, objects created by the Server.CreateObject method have page scope. This means that they are automatically destroyed by the server when it finishes processing the current ASP page.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply