Avatar of brihol44
brihol44
 asked on

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

Avatar of undefined
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>
ASKER CERTIFIED SOLUTION
_agx_

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23