Solved

# Outputting Checkboxes 3 To A Row

Posted on 2005-04-26
Medium Priority
172 Views
I want to acheive a table format displaying checkboxes evenly over three columns ,

eg.. if there is 9 checkboxes:  -

A                          D                                G
B                          E                                 H
C (New Column)    F (New Column)            I

if there is 3 checkboxes

A                         B                                  C

if there is 10 checkboxes

A                       E                       I
B                       F                       J
C                       G
D                       H

Code so far

<tr align="left">
<!--- Output  Sectors --->
<cfoutput query="Get_Sectors">
<cfif CurrentRow MOD 3 eq 1><td width="2%"></cfif>
<input type="Checkbox" name="sectors" value="#Get_Sectors.sectorid#" <CFIF FORM.sectors contains
Get_Sectors.sectorid>CHECKED="yes"</cfif>> #Get_Sectors.sector#<br>
<cfif currentRow MOD 3 eq 0 OR currentRow eq recordcount></td></cfif>
</cfoutput>
</tr>
</table>

Any ideas would be much appreciated !
JT
0
Question by:jturkington
• 2

LVL 9

Expert Comment

ID: 13868676
You still hanve not awarded the points for this question Q_21402833.html

anyways is kind of what you are after?
http://think-lab.net/ee.cfm
0

LVL 9

Expert Comment

ID: 13868730
What do you want it to look like when you have between 4 and 6 records
0

LVL 1

Accepted Solution

dillusion13 earned 2000 total points
ID: 13869668
Here's a solution, not the best but works.

<cfif get_sectors.recordcount mod 3 is 0 >
<cfset num = get_sectors.recordcount/3>
<cfset wn = int(num)>
<cfset rd = num>
<cfelse>
<cfset num = get_sectors.recordcount/3>
<cfset wn = int(num)>
<cfset rd = wn + 1>
</cfif>

<tr align="left">
<!--- Output  Sectors --->
<cfset rc = 1>
<cfoutput query="Get_Sectors">
<cfif rc is 1>
<td width="2%" valign="top">
</cfif>
<input type="Checkbox" name="sectors" value="#Get_Sectors.sectorid#" <CFIF FORM.sectors contains Get_Sectors.sectorid>CHECKED="yes"</cfif>>#Get_Sectors.sector#<br>
<cfif rc IS rd or get_sectors.recordcount is currentrow>
<cfset rc = 1>
<!--- 4 records is an exception --->
<cfif get_sectors.recordcount is 4>
<cfset rd = 1>
</cfif>
</td>
<cfelse>
<cfset rc = rc+1>
</cfif>

</cfoutput>
</tr>
</table>
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under \$99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
###### Suggested Courses
Course of the Month12 days, 15 hours left to enroll