Okay...Now I just need to do my homework, and try to make this happen.  Will 
let you know how it all works out.

Thanks so very much for taking the time to respond.
Donna

PS - I'm hoping not, but I 'may' be back with more questions...

________________________________________
From: Eric Nicholas Sweeney [[email protected]]
Sent: Monday, July 26, 2010 2:14 PM
To: cf-newbie
Subject: RE: Two dropdown's - Second populated by the first

Here is what I do - based on: http://tutorial11.easycfm.com/

I store the Categories and Subcategories in the database and then query them
to build the javascript. The real trick is getting the Query to get your
categories/selections correctly aligned. After that - the rest falls into
place.

 - Nick

First - Query then setup the Javascript:

<cfquery name="qryGetCats" datasource="#Application.DSN#">
    SELECT s.SubCatID, s.SubCatName, c.CatName, c.CatID
    FROM WT_SubCategories s
    INNER JOIN WT_Categories c ON s.CatID = c.CatID
    ORDER BY CatName desc, SubCatName
</cfquery>

    <cfset idx = -1>
    <cfset mycase = 0>
    <!---
       The JavaScript is adapted from Mike Corbridge's Multiple dynamic
drop-down selection boxes example http://tutorial11.easycfm.com/
    --->
    <script language="JavaScript1.2">
        function whichCategory(obj){
                    switch (obj.selectCategory.selectedIndex){
                    <!--- use the group attribute to group output by
category --->
                    <cfoutput query="qryGetCats" group="CatName">
                    <cfset mycase = mycase + 1>case #mycase#:
                    <cfset myList = ValueList(qryGetCats.CatID)>
                    <cfset numberInCategory = ListValueCount(myList, CatID)>


obj.selectSubCat.length=#numberInCategory#<cfoutput><cfset idx = idx + 1>

obj.selectSubCat.options[#idx#].value="#qryGetCats.SubCatID#"

obj.selectSubCat.options[#idx#].text="#qryGetCats.SubCatName#"</cfoutput>
                         break;

                    <cfset idx = -1>
                    </cfoutput>
                    }
       }
    </script>


And for the FORM I use this:

         <option value="">- Select Category -</option>
         <!--- again, use the group attribute to group output by category
--->
         <cfoutput query="qryGetCats" group="CatName">
         <option value="#CatID#">#CatName#</option>
         </cfoutput>
       </select>

       <select name="selectSubCat" onchange="whichCategory(this.form)">
          <option value=""> <- First Select Category</option>
      </select>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5051
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to