Populate drop down by another drop down

Posted on 2004-11-29
Last Modified: 2013-12-24
Hi guys,
     Its another question about ColdFusion. Sorry about being a ColdFusion newbie. I need to know how to populate a drop down list from another drop down list. For example, I have a table named Plan that contains uniquely identifying fields Part_Num and Typer (both of which comprise the PK). I want to be able to select a Part_Num from a list (select distinct Part_num from Plan), and have the selection dynamically populate a second drop box (select distinct Typer from Plan where Part_Num = '[ENTER SELECTION CHOSEN FROM FIRST DROP BOX]'). I want to do that within the same page without refreshing the page if possible. Could someone please provide the code to do this? Thanks!
Question by:jl_forum
    LVL 8

    Accepted Solution

    Sound like using CF_TwoSelectsRelated custom tag  should work for you.

    <CFQUERY NAME="TestSelection" DATASOURCE="yourDataSource">
     SELECT distinct Part_Num,Typer
     FROM Plan
     ORDER BY Part_Num,Typer

    <TABLE align="CENTER" width="98%">
    <TD align="CENTER" height="100" valign="MIDDLE">
          htmlbetween="</TD><TD ALIGN='CENTER' VALIGN='MIDDLE'>"

    LVL 8

    Expert Comment

    you can download the free CF_TwoSelectsRelated custom tag using the link below if have not already have the tag.

    Author Comment

    Hi Martin,
        I had actually looked at this tag before submitting my question to EE. I didn't understand what I was supposed to do to this code. It appears to be a template and I just have to fill items in. However, I am unsure of what to do and the "directions" don't make much sense to me. Remember, I'm pretty much a newbie. Can you tell me what to do? Thanks.
    LVL 5

    Expert Comment

    have a look at the following links

    very easy and quick way to set up dynamic drop down lists

    Pull down list based on the selection in another pull down list

    populate select list based on other list selection
    LVL 8

    Expert Comment

    JL - What Coldfusion Version are you using?

    If you have V5.0, then the custom tag CF_TWOSELECTSRELATED is already build in for you.  You can use my example above to get you selection works.

    If you are using V4.5, then there's a default folder for custom tag   "C:\CFusion\CustomTags" - u'll need to store ur files from the zip file you download from the link above there


    Author Comment

        I tried pasting your code. All I get is a white screen even though I have it in the custom tags directory and am using Coldfusion MX 6.1 (Trial). Any ideas? I don't see a table or anything on screen....

    Author Comment

    Nevermind.. my mistake! Thanks! It works... however, an error message always appears when I use it. Its a runtime error from IE... it may just be my IE?

    A Runtime Error has occured.
    Do you wish to Debug?

    Error: Object expected

    Any ideas? Thanks.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following:…
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now