I would like to add a field for adding adding sub-categories within my coldfusion query output
I have my cfoutput working just fine like so....
<cfoutput query="test" group="record_ID">
Main Category
<cfoutput>
Sub Category
<cfoutput>
</cfoutput>
I would like to add a field though for adding sub-categories like so....
<cfoutput query="test" group="record_ID">
Main Category 1
<cfoutput>
1 input field and submit button to add more sub-categories then list all sub-categories
Sub Category 1
Sub Category 2
Sub Category 3
<cfoutput>
</cfoutput>
I'm wondering if using a cfloop is the way to go but I'm hoping to have the 1 field be at the top or above all sub-categories and below the main categories so the user can enter in more sub-categories.
Thanks,
Brian
ColdFusion Language
Last Comment
_agx_
8/22/2022 - Mon
gdemaria
Sure, you can add a CFIF statement with a flag each time the category changes like this..
This will show only one field for every category..
<cfoutput query="test" group="record_ID">
Main Category 1
<cfset newCategory = true>
<cfoutput>
<cfif newCategory>
1 input field and submit button to add more sub-categories then list all sub-categories
<cfset newCategory = false>
</cfif>
Sub Category 1
Sub Category 2
Sub Category 3
<cfoutput>
</cfoutput>
This will show only one field for every category..
<cfoutput query="test" group="record_ID">
Main Category 1
<cfset newCategory = true>
<cfoutput>
<cfif newCategory>
1 input field and submit button to add more sub-categories then list all sub-categories
<cfset newCategory = false>
</cfif>
Sub Category 1
Sub Category 2
Sub Category 3
<cfoutput>
</cfoutput>