Search code examples
coldfusioncfmlcfloop

Avoid duplicate with nested cfoutput and cfloop


I have made a dynamic form that combines a list of individuals. In this list, I have a field that contains the values of a dynamic list. My concern is that this field (#id_p#_state) is multiplied by the initial query and I want to avoid that. the result I have is for example if I have 10 results in the first query, each line of the second is x10

<cfinvoke component="cfc_query" method="methode_h" returnvariable="result">
    <cfinvokeargument name="id_atser"  value="#id#">
</cfinvoke>

<cfinvoke component="cfc_query" method="methode_state" returnvariable="result_state">
</cfinvoke>  
 <cfoutput query="result">
     <tr>
         <td>#lastname# #firstname# #id_personne#</td>
         <cfloop from="1" to="#daysInMonth(createdate(datepart('yyyy',now()),form.date_periode,1))#" index="boucle">
             <td><cfinput name="#id_personne#_date_presence" type="text" value="#dateformat(createdate(datepart('yyyy',now()),form.date_periode,boucle),'dd/mm/yyyy')#" size="7"></td>
             <td>
                 <cfselect name="#id_p#_state" style="width: 32px;">
                     <cfloop query="result_state">
                       <cfoutput>
                         <option value="#id_state#">#description#</option>
                       </cfoutput>
                     </cfloop>
                 </cfselect>
             </td>

         </cfloop>
     </tr>
 </cfoutput>

Solution

  • You have a CFOUTPUT nested inside of a CFOUTPUT loop.

    Get rid of the redundant CFOUTPUT around your option tag and this should clean up your output.