<cfquery name="veegan" datasource="fuz">
SELECT 
                category.category,
                fruit_veggie.name
FROM
                category
INNER JOIN 
                fruit_veggie
ON
                category.categoryID = fruit_veggie.categoryID
</cfquery>

<cfquery name="cat" datasource="fuz">
SELECT 
                *
FROM
        category
</cfquery>

<!---cfdump var="#veegan#" /--->

<script type="text/javascript">
var myArray = new Array();
<cfoutput>
        <cfloop from="1" to="#cat.recordCount#" index="i">      
                myArray['#cat.category[i]#'] = new Array();
                <cfloop from="1" to="#veegan.recordCount#" index="j">
                        <cfif #veegan.category[j]# EQ #cat.category[i]#>
                                
myArray['#cat.category[i]#'][myArray['#cat.category[i]#'].length]
= '#veegan.name[j]#';
                        </cfif>
                </cfloop>
        </cfloop>
</cfoutput>

function fillThatBox(theCategory) {
alert(theCategory);
document.fuz.items.options.length = 0;
        for(var i=0;i<myArray[theCategory].length; i++) {
                document.fuz.items.options[document.fuz.items.options.length] = 
new
Option(myArray[theCategory][i]);
        }
}

</script>

<cfoutput>
<form name="fuz">
<select name="cat"
onchange="fillThatBox(this.options[this.selectedIndex].value);">
        <cfloop from="1" to="#cat.recordCount#" index="i">
                <option value="#cat.category[i]#">#cat.category[i]#</option>    
        </cfloop>
</select>
<!---yes items :) --->
<select name="items" size="1" style="width:150px;">
        <option value=""></option>

</select>
</form>
</cfoutput>

you could eliminate the second query and do a group


On Wed, 9 Feb 2005 13:26:39 -0800 (PST), Discover Antartica
<[EMAIL PROTECTED]> wrote:
> I want to display the data in two select boxes.  For example, I want to 
> display two select boxes. In the first one I want to display the list of the 
> category of employees (like full time, part time, contract, etc)
> 
> On the second select list i want to display the list of employees in that 
> category. For example, if the user clicks on the part time then the second 
> box should display all part time employees only.
> 
> Is there a easy way for this?
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:193963
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to