Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

checkboxes and coldfusion

Posted on 2008-06-13
4
Medium Priority
?
273 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
  • 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 2000 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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

564 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