?
Solved

Outputting Checkboxes 3 To A Row

Posted on 2005-04-26
3
Medium Priority
?
172 Views
Last Modified: 2013-12-24
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

<table cellpadding="0" cellspacing="0" border="0">
<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
Comment
Question by:jturkington
  • 2
3 Comments
 
LVL 9

Expert Comment

by:CFDevHead
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

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

Accepted Solution

by:
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>


<table cellpadding="0" cellspacing="0" border="0">
<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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question