Solved

Help dynamically build the table in coldfusion

Posted on 2008-06-24
2
160 Views
Last Modified: 2013-12-24
I have a list of courses,(which is dynamic rign now 2 courses but could be more). I Nedd to check the completion for that courses and output it into the HTML table. First i am trying to loop through the courses and get the completion, and then output it into the table

But unfortunately it did not work
 

lcourse is list of courses
<cfloop from="1" to="#ListLen(lcourse)#" index="i">

	<!---	<cfset qName="checkCompletion" &i>--->

			<cfquery name="qName" datasource="cfelsunrise" dbtype="ODBC">

				Select completiondate from EmployeeTraining where EmployeeID=#EmployeeID# and courseID in (#lcourse#)

			</cfquery>
 

	</cfloop>

	<cfloop from="1" to="#ListLEn(lcourse)#" index="i">

	<td align="center" width="2%" <cfif qName.completiondate is not "">bgcolor="##00FF00"<cfelse>bgcolor="##FF0000"</cfif>></td>

	

	</cfloop>

	</tr>

	

	</cfoutput>

Open in new window

0
Comment
Question by:erikTsomik
2 Comments
 
LVL 4

Expert Comment

by:JillofallTradesMistressofNone
Comment Utility
Hi.   Where is your opening cfcoutput tag?  Is it just not in this code sample?  Check out this page for help on cfloops and output:  http://www.quackit.com/coldfusion/tutorial/coldfusion_loops.cfm

Good luck!
0
 
LVL 2

Accepted Solution

by:
adobe116 earned 500 total points
Comment Utility
Hey, I think you want to delete lines 7 and 8.  You should only loop through the list once.

Also, instead of checking to see if something equals "", simply check if it's length is > zero.

I changed that in your code.  Best of luck.
<cfoutput>

<table>

<tr>

<cfloop from="1" to="#ListLen(lcourse)#" index="i">

	<!---	<cfset qName="checkCompletion" &i>--->

	<cfquery name="qName" datasource="cfelsunrise" dbtype="ODBC">

	Select 

		completiondate 

	from 

		EmployeeTraining 

	where 

		EmployeeID = #EmployeeID#

		and

		courseID in (#lcourse#)

	</cfquery>

 

	<td align="center" width="2%" <cfif len(qName.completiondate)>bgcolor="##FF0000"<cfelse>bgcolor="##00FF00"</cfif>>#yourContent#</td>

</cfloop>

</tr>

</table>

</cfoutput>

Open in new window

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now