I have a loop that totals values submitted from a form. A query outputs a number of fields, to which a name is assigned by going through a list. then the loop sees which checkboxes have been checked and creates totals from the checkboxes that correspond to each field. My problem is that i have created a next 5 button that submits to the same page it is on, and therefore goes through the list and does the totals again! any ideas how to stop it doing that? i have named the next 5 button so i can say
<cfif isdefined("nextstart"
>
then dont retotal, use previous totals, but cant work out what should go in here!
</cfif>
here is the code that totals the values and assigns a session variable.....
<CFLOOP QUERY="QSections">
<!--- For each section record... --->
<cfset total=0> <!--- Initialise total --->
<CFSET SrchName="SrchCat"&QSections.CurrentRow> <!--- Create form variable name --->
<CFSET SessName="session.SrchCat"&QSections.CurrentRow>
<!--- <TD>#secName#</TD><TD>#SrchName#-</TD> ---> <!--- Show section name and form variable name --->
<CFIF IsDefined("#SrchName#"
> <!--- If form variable was passed from search page, e.g. SrchCat1, SrchCat2, etc. --->
<CFSET theList=Evaluate(SrchName)> <!--- Assign to theList string of numbers from search page --->
<!--- <TD> --->
<cfloop index="num" list=#theList#> <!--- Loop the list --->
<cfset total=total + num> <!--- accumulate values --->
<!--- #num#, ---> <!-- show current value in table -->
</cfloop>
<CFSET "#SessName#"=#total#>
<!--- </TD>
<TD>#total#</TD> --->
<!-- Show total in table -->
<CFELSE>
<!--- <TD>not passed from search page.</TD> ---><TD> </TD> <!-- Does not exist --><CFSET "#SessName#"=0>
</cfif>
</cfloop>
<cfif isdefined("nextstart"
then dont retotal, use previous totals, but cant work out what should go in here!
</cfif>
here is the code that totals the values and assigns a session variable.....
<CFLOOP QUERY="QSections">
<!--- For each section record... --->
<cfset total=0> <!--- Initialise total --->
<CFSET SrchName="SrchCat"&QSections.CurrentRow> <!--- Create form variable name --->
<CFSET SessName="session.SrchCat"&QSections.CurrentRow>
<!--- <TD>#secName#</TD><TD>#SrchName#-</TD> ---> <!--- Show section name and form variable name --->
<CFIF IsDefined("#SrchName#"
<CFSET theList=Evaluate(SrchName)> <!--- Assign to theList string of numbers from search page --->
<!--- <TD> --->
<cfloop index="num" list=#theList#> <!--- Loop the list --->
<cfset total=total + num> <!--- accumulate values --->
<!--- #num#, ---> <!-- show current value in table -->
</cfloop>
<CFSET "#SessName#"=#total#>
<!--- </TD>
<TD>#total#</TD> --->
<!-- Show total in table -->
<CFELSE>
<!--- <TD>not passed from search page.</TD> ---><TD> </TD> <!-- Does not exist --><CFSET "#SessName#"=0>
</cfif>
</cfloop>