Solved

checkboxes and coldfusion

Posted on 2008-06-13
4
263 Views
Last Modified: 2013-12-24
I have a number od checkboxes that i am need to insert the completion date into the database. So if the check box is checked insert the todays date into the dataabse for that Employee it was checked . and I am getting the error saying that <cfloop does not have closing tag

My action page is here
<cfif isDefined("form.btnSubmit")>
<cfloop index="variables.i" from="1" to="#ListLen(form.ch)#">
           <cfset variables.thisCheckbox = ListGetAt(form.ch,variables.i)>

           <cftry>
           <cfquery name="insertCompletion" datasource="cfelsunrise" dbtype="ODBC">
                        INsert into EmployeeTraining (CompletionDate,StartDate,EmployeeID,CourseID,CourseName,EnteredBy) values
                        (variables.thisCheckbox,getDate(),#form.employeeID#,1661,'REM JOURN DISC',#session.EmpID#)

            </cfquery>
            <cfcatch type="database">
              There was a database error!
            </cfcatch>
         </cftry>

</cfloop>
<!---<cflocation url="rem_dashboard.cfm" addtoken="no">--->
</cfif>
And the code is here 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<cfquery name="getCareManagers" datasource="cfelsunrise" dbtype="ODBC">
		<!--- Executive Director --->
        select e.employeeid ,e.last_name as lname,e.first_name as fname,ej.JobCode,l.name
		from Employee e
		join EmployeeJobHistory ej			ON ej.EmployeeID = e.EmployeeID
		inner join JobAssignment ja			on ej.sequence = ja.sequence
		inner join location l on ja.locationId=l.locationId
 
		where  ja.EndDate is NULL and l.locationID=#session.Locationid# AND (ej.JobCode = '1001' or ej.JobCode = '1101' or ej.JobCode = '1007')
		order by lname
	</cfquery>
 
 
 
<body>
<form name="frmCheck" action="checkCompletion.cfm" method="post">
<h2 align="center">Reminiscence Training</h2>
<h3 align="center">REM JOURN DISC</h3>
<table width="50%" align="center">
	<tr>
		<th>Name</th>
		<th width="36%">Location</th>
		<th>Job Code</th>
		<th>Section1</th>
		
		
	
	
	</tr>
<cfset lastEmp=''>
 
<cfoutput query="getCareManagers">
<input type="hidden" name="EmployeeID" value="#EmployeeID#" />
<cfif lastEmp is not #EmployeeID#>
	<cfquery name="checkCompletion" datasource="cfelsunrise" dbtype="ODBC">
		select * from EmployeeTraining where EmployeeID=#EmployeeID# and completionDate is not null and courseID=1661
	
	</cfquery>
	
	<tr>
		<td width="39%">#lname#,#fname#(#EmployeeID#)</td>
		<td align="center">#name#</td>
		<td align="center">#jobCode#</td>
		<td align="center" width="25%"><input type="checkbox" name="ch" value="#DateFormat(now(),"mm/dd/yyyy")#"  /></td>
	</tr>
 
<cfset lastEmp=#EmployeeID#>
</cfif>
</cfoutput>
 
<tr>
<td align="left" colspan="1"><cfoutput><strong style="font-size:16px">Total:#getCareManagers.recordcount#</strong></cfoutput></td>
<td align="right" colspan="1"><input type="submit" name="btnSubmit" id="btnSubmit" value="Complete The Course" /></td>
</tr>
</table>
 
<cfoutput>
<input type="hidden" name="counter" value="#getCareManagers.recordcount#">
 
</cfoutput>
</form>
 
</body>
</html>

Open in new window

0
Comment
Question by:erikTsomik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 21785105
first off
one would want to do something like:
<input type="checkbox" name="#EmployeeID#"> instead of name="ch" value="#now()# ..."
and it looks like you want to group so you can remove the empid thing and do
<cfoutput query="getCareManagers" group="EmployeeID">

and on action page
<cfif StructKeyExists(form,"EmployeeID")>
      <cfloop list="#form.EmployeeID#" index="ii">
            <cfif StructKeyExists(form,ii)>
                  <cfquery name="insertCompletion" datasource="cfelsunrise" dbtype="ODBC">
                  insert into EmployeeTraining
                  (CompletionDate,StartDate,EmployeeID,CourseID,CourseName,EnteredBy)
                  values
                  (getDate(),getDate(),#ii#,1661,'REM JOURN DISC',#session.EmpID#)            
                  </cfquery>
                  note: where you are inserting completiondate - on the form you appeared to want to set to now() so why not just set to getDate()? but then one wonders why completion and start are the same ???
            </cfif>
      </cfloop>
</cfif>
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 21785303
I try this and it does not insert a record into the dataabse
I change the code to
<cfoutput query="getCareManagers">

<cfif lastEmp is not #EmployeeID#>
      <cfquery name="checkCompletion" datasource="cfelsunrise" dbtype="ODBC">
            select completiondate from EmployeeTraining where EmployeeID=#EmployeeID#  and courseID=1661
      
      </cfquery>
      
      <tr>
            <td width="39%">#lname#,#fname#(#EmployeeID#)</td>
            <td align="center">#name#</td>
            <td align="center">#jobCode#</td>
            <td align="center" width="25%">
      
            <cfif checkCompletion.completiondate neq "">
            <input type="checkbox" name="#EmployeeID#" value="#now()#" checked="checked" disabled="disabled" class="green"/>
            <cfelse>
            <input type="checkbox" name="#EmployeeID#" value="#now()#" />
            </cfif>
            </td>
      </tr>

<cfset lastEmp=#EmployeeID#>
</cfif>
</cfoutput>

And action page to
<cfif isDefined("form.btnSubmit")>
<cfif StructKeyExists(form,"EmployeeID")>
      <cfloop list="#form.EmployeeID#" index="ii">
            <cfif StructKeyExists(form,ii)>
                  <cfquery name="insertCompletion" datasource="cfelsunrise" dbtype="ODBC">
                  insert into EmployeeTraining
                  (CompletionDate,StartDate,EmployeeID,CourseID,CourseName,EnteredBy)
                  values
                  (getDate(),getDate(),#ii#,1661,'REM JOURN DISC',#session.EmpID#)            
                  </cfquery>
                 
            </cfif>
      </cfloop>
     
</cfif>
<cflocation url="rem_dashboard.cfm" addtoken="no">
</cfif>
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 21785340
it looks like you removed your
<input type="hidden" name="EmployeeID" value="#EmployeeID#" />
from your form
the form field EmployeeID is tested for or an insert won't happen
and why not just add the checkCompletion query to the getCareManagers query???
however you do it you can streamline by doing:
<input type="checkbox" class="green" name="#EmployeeID#" <cfif isDate(checkCompletion.completiondate)>disabled="disabled" checked</cfif>/>

note: you can remove your if isdefined("form.btnsubmit") block
0
 
LVL 19

Author Closing Comment

by:erikTsomik
ID: 31467071
Great job
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

726 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