Skip to main content
August 21, 2011
Question

How to create two select dropdown menus that are related

  • August 21, 2011
  • 1 reply
  • 429 views

I tried the CF_twoselectsrelated but it is supposing you only have 1 query.

I have a query that selects categories and another one that selects subcategories - maybe that is where I am going wrong. the queries are:

SELECT
        T_categories_ID
        ,T_categories_name as categoryname
    FROM
        T_categories
    WHERE
        T_categories_ID > 0
         AND
        T_categories_subcat_ID = 0
        AND
        T_categories_active = 1
        AND
        T_categories_partnerID =  #session.partnerid#
    ORDER BY T_categories_name ASC

And the other one is

SELECT
        T_categories_autoid,
        T_categories_subcat_ID,
        T_categories_subcat_name as subcatname,
        T_categories_subcat_description as description,
        T_categories_subcat_img, T_categories_imgname
    FROM
        T_categories
    WHERE
        T_categories_partnerID = #session.partnerid#  AND
        T_categories_subcat_Parent = #attributes.categoryID#
    ORDER BY
        T_categories_ID,
        T_categories_subcat_name ASC

The categories and subcategories are in one table (was not my idea:-))

Please can anyone point me in the right direction??

Bianca

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 21, 2011

    Do you mean the stuff from here:

    http://projects.nateweiss.com/nwdc/workcode.htm

    ?

    If so, to be honest, don't ("use it", I mean).

    It might have been a reasonable approach to this sort of thing ten years ago, but it's not a very good way of doing this sort of thing these days.

    This sort of thing is pretty easy to knock together with some HTML, JQuery to do some JS stuff and a CFC behind the scenes.

    Indeed just using some binds to <cfselect> tags would be a better approach.

    --

    Adam

    August 21, 2011

    Hi Adam,

    It is indeed this one I was talking about.

    I tried it with bind, in a ' normal' form that works but in this case there

    is a flash application involved and things go wrong when I use cfform

    instead of form - which is necessary when using bind.

    You say there are better solutions, I have been googl-ing all day but didn't

    really find something that seemed easy to use.

    Bianca

    Inspiring
    August 21, 2011

    I just googled "jquery link two select boxes" and there were a few good matches there.

    --

    Adam