1 Reply Latest reply on Jun 8, 2009 6:53 AM by gdmprog1

    Parent Child dropdown list in ColdFusion

    meeyaw

      Hi,

       

      I'm looking a CF/Javascript code with a functionality to show a parent dropdown list (ex. Country) and depending on the selected Country, need to show the child (State) dropdown list.

       

      Thanks.

        • 1. Re: Parent Child dropdown list in ColdFusion
          gdmprog1

           

           

          This will create a tree just like Windows Explorer. The "Cancelled Accounts" and the "Current Accounts" are folders and the accounts are pages.

           

          <!--- list of all cancelled accounts --->

          <cfquery name="Accounts1" datasource="readprod" dbtype="ODBC">
          select accountinfo, ACCOUNT_NUM, web_acct_num_plain, value, code, category_code
          from directbilltext
          where (AGENT_NUM = '#SESSION.Usercode#')
                 AND(CATEGORY_CODE = code)
                 and (CATEGORY_CODE = '3')
            order by account_num
          </cfquery>

           

          <!--- list of all current accounts --->

          <cfquery name="Accounts2" datasource="readprod" dbtype="ODBC">
          select accountinfo, ACCOUNT_NUM, web_acct_num_plain, value, code, category_code
          from directbilltext
          where (AGENT_NUM = '#SESSION.Usercode#')
            AND(CATEGORY_CODE = code)
            and (CATEGORY_CODE = '4') and
             order by account_num
          </cfquery>

           

          <!--- beginning of tree. Parent levels are Cancelled Accounts and Current Accounts --->

          <cf_dccom component="TreeControl" width="400" height="250" usecookies="YES" title="Personal Lines Accounts">

               <cfset next_item = 1>
               <cfset current_parent = #next_item#>

               <cf_dccom id="#next_item#" parent="0" display="Cancelled Accounts" expand="false" ></cf_dccom>
               <cfloop query="Accounts1">
                    <cfset next_item = #next_item# +1>
                    <cf_dccom id="#next_item#" parent="#current_parent#" display="#accountinfo#"
                              HREF="/public/reports/Pers_history.htm?cftreeitemkey=#web_acct_num_plain#">

                    </cf_dccom>
               </cfloop>

               <cfset next_item = #next_item# + 1>
               <cfset current_parent = #next_item#>

               <cf_dccom id="#next_item#" parent="0" display="Current Accounts" expand="false" ></cf_dccom>
               <cfloop query="Accounts2">
                    <cfset next_item = #next_item# +1>
                    <cf_dccom id="#next_item#" parent="#current_parent#" display="#accountinfo#"
                              HREF="/public/reports/Pers_history.htm?cftreeitemkey=#web_acct_num_plain#">

                    </cf_dccom>
               </cfloop>

          </cf_dccom>

          So you could have a list of your countries with a list of your