Skip to main content
Participating Frequently
June 2, 2009
Question

Multiple Columns and List Order with Color

  • June 2, 2009
  • 2 replies
  • 602 views

I am trying to take this code and enhance it by:

1. It currently displays the output in a 5 column vertical format

output1 output2 output3...

I want it to display in a scrolling 5 column vertical format

output1  output4
output2  output5
output3  output6

based on the number of data points

2. I want the first column background to be blue, the next white, the next blue, the next white, the last blue.

Any way to accomplish this..appreciate any help.

Leo

Code:

<table width="100%" border="0" cellpadding="7" cellspacing="0">
<tr>
<td colspan="5" align="left" valign="top" bgcolor="#CC6699">
<span class="datetextwhite"><a name="THURSDAY"> </a><span class="style6">Thursday, October 29th: PRE-CONFERENCE INTENSIVES</span></span></td>
</tr>
     <TR>
     <CFOUTPUT QUERY="q_daysschedule">
          <TD valign=top><span class="bodytextbold"><span class="style16"><font face="Verdana, Arial, Helvetica, sans-serif">#q_daysschedule.time#</font></span></span><br /><span class="topNavigationBar"><a href="session.cfm?ID=201" class="topNavigationBar">#q_daysschedule.Title#</a></span></TD>
          <CFIF q_daysschedule.CurrentRow MOD 5 IS 0>
               </TR>
               <TR></TR>
          </CFIF>
     </CFOUTPUT>
<tr>

This topic has been closed for replies.

2 replies

lfred150Author
Participating Frequently
June 2, 2009

The output is coming from a cfquery and this may not work (I may not understand the coding of that)..I really liked the simplicity of the code that I was using and did not know if there was a way to modify that to come up with my ultimate solution.

Leo

Inspiring
June 2, 2009

I find these problems easier to solve if I rearrange my data into an array.  Something like this:

DataArray = ArrayNew(2);

Cols = 5;

Outputs = "output1,output2,etc";

Rows = Round(ListLen(Outputs) / Cols + .5);    // 32 outputs would give you 7 rows

for (ii = 1; ii lt cols; ii = ii + 1) {

for (j = 1; j lte Rows; j = j + 1) {

DataArray[ii] = ListFirst(Outputs);

Outputs = ListRestOutputs;

} // rows

}  // cols

// Last Column

for (ii = 1; ii lte ListLen(Outputs); ii = ii + 1 )

DataArray[cols][ii] = ListGetAt(outputs, ii);

// put spaces in blank rows

for (j = ii; j lte rows; j = j + 1)

DataArray[cols] = " ";

Output like this

<cfoutput>

<cfloop from = "1" to = cols index = "ThisRow">

<cfloop from = "1" to = rows index = "ThisCol">

#DataArray[ThisCol][ThisRow]#

closing tags, formatting etc