I don't see any nested loops in the code below. So the simple answer here is to 
just declare some variables outside of the loop to manage the sums. As long as 
the variable is outside the loop, you'll be set:

<cfset answervalueTotal = 0 />
<cfset totalforthisquestionTotal = 0 />
<cfset answerpercentageTotal = 0 />
<cfoutput> 
  <cfset answervalueTotal = answervalueTotal + answervalue />
  <cfset totalforthisquestionTotal = totalforthisquestionTotal + 
totalforthisquestion />
  <cfset answerpercentageTotal = answerpercentageTotal + answerpercentage />
 <table style="float:left; width:50px; text-align:center; font-size:11px; 
border:1px solid ##CCCCCC; 
margin:5px; vertical-align:top; background-color:##F7F7F7;">
         <tr>
           <td style="border: 1px solid ##CCCCCC;">#answervalue#</td>
         </tr>
         <tr>
           <td style="border: 1px solid 
##CCCCCC;"><strong>#totalforthisquestion#</strong></td>
         </tr>
         <tr>
           <td style="border: 1px solid 
##CCCCCC;"><strong>#NumberFormat(answerpercentage, "__
")#%</strong></td>
         </tr>
 </table>
</cfoutput>
<!--- display sums --->
<cfoutput>
 #answervalueTotal#<br />
 #totalforthisquestionTotal#<br />
 #answerpercentageTotal#<br />
 <!--- and just for fun, we'll display the average percentage too --->
 <cfset averageAnswerPercentage = answerpercentageTotal / yourQuery.recordcount 
/>
 #averageAnswerPercentage#
</cfoutput>


 
 
  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275271
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to