aliashippysmom
Programmer
Hi! I have a problem which is something I can't quite figure out. I have a two part form. The user enters a number on the first form and hits SUBMIT. Based on that number, an input table is generated on the second form. If we assume the user enters 7 for the number of items, the input table on the second screen would look like this. I need a maximum of 6 items per line. txt is a input of type text and chk is input of type checkbox. The user will enter values across the page for each Call Center.
Call Center # 1 2 3 4 5 6
Call Center Loc txt txt txt txt txt txt
Virtual chk chk chk chk chk chk
Call Center # 7
Call Center Loc txt
Virtual chk
Here's my test code so far:
I hope this makes some sense. It seems to work o.k. if the number of items is greater than 12. Can anyone help?
Call Center # 1 2 3 4 5 6
Call Center Loc txt txt txt txt txt txt
Virtual chk chk chk chk chk chk
Call Center # 7
Call Center Loc txt
Virtual chk
Here's my test code so far:
Code:
<cfset numitems = 10> NUMBER OF ITEMS FROM FIRST FORM
<cfset remainder = numitems MOD 6>
<cfset total = numitems>
<cfset flag = 0>
<cfset num1 = 1>
<cfset num2 = 1>
<cfset r = min(#numitems#,6)>
<cfloop condition="#numitems# GT 0">
<table>
<tr><td>Call Center #</td>
<cfloop index="j" from="#num1#" to="#r#">
<td><cfoutput>#j#</cfoutput></td>
</cfloop>
</tr>
<tr><td>Call Center Location</td>
<cfloop index="k" from="#num2#" to="#r#">
<td><cfoutput>#k#</cfoutput></td>
</cfloop>
</tr>
</table>
<cfset numitems = #numitems# - #r#>
<cfif numitems LT 0 and flag EQ 0>
<cfset numitems = remainder>
<cfset flag = 1>
</cfif>
<cfoutput>Numitmes = #numitems#</cfoutput>
<cfset num1 = num1 + 6>
<cfset num2 = num2 + 6>
<cfset r = r + #min(numitems,6)#>
<cfif r GT total>
<cfset r = remainder>
</cfif>
</cfloop>