[thelist] [CFand JavaScript]: Two Select boxes dynamically generated

rudy r937 at interlog.com
Tue Nov 5 10:21:01 CST 2002


> If this is the last item in the Group output,
> the trailing comma does not need to be there.

hi susan

many people use trailing commas, i prefer leading commas

for example,

   <CFOUTPUT Query="GetProcessSteps" Group="PSID">
   new Array(
   <CFSET comma="">
   <CFOUTPUT>
   #comma# new Array("#JSStringFormat(PSDesc)#", #PSID#)
   <CFSET comma=",">
   </CFOUTPUT>
   ),
   </CFOUTPUT>

does that make sense?  the output looks like this --

   new Array(
     new Array("Communicate these ...", 2)
   , new Array("Each student will ...", 3)
   , new Array("Provide all students ", 4)
   ),

notice i did not include your dummy last row new Array("", 0)

i use a string called comma, which starts out as an empty string and is
reset as soon as the first row inside the group is encountered

i like leading rather than trailing for the simplicity it gives to GROUP=
logic

each group has at least one row (otherwise it's not even there, eh    ;o)

with a trailing comma strategy, you can't even print the first row because
you don't know that there's a second one coming or not

the first row of a group has no comma in front of it (another fine
example of a classic duh moment the first time i truly realized this),
and subsequent rows all have a comma in front of them

i've not seen trailing comma logic as simple as that


> How can I determine the count of a grouped output?

while this is certainly not the only way to do it, you could pre-generate
group counts by bringing them back in the database query

example and coldfusion code here --

  Group totals and details in one database query
  http://r937.com/grouptotals.htm


rudy






More information about the thelist mailing list