|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Tracking Time
I am trying to develop a script that I can use to track my time by pushing a button for my start time and another button for my stop time, then subtracting the difference to save to a database.
I came up with the following script, but when I push the End Time button ,the start time is erased. Does anyone have any better ideas? Any help would be appreciated. <table border="1"> <tr> <td> <FORM action="#getfilefrompath(cgi.script_name)#" method="post"> <input type="submit" name="operation" value="Start Time"> </form> </td> <td> <FORM action="#getfilefrompath(cgi.script_name)#" method="post"> <input type="submit" name="operation" value="End Time"> </form> </td> </tr> <tr> <td> <cfif isdefined("operation")> <cfif #form.operation# IS "Start Time"> <cfset StartTime = "#timeFormat(now(), "HH:mm:ss")#"> #StartTime# </cfif></cfif> </td> <td><cfif isdefined("operation")> <cfif #form.operation# IS "End Time"> <cfset EndTime = "#timeFormat(now(), "HH:mm:ss")#"> #EndTime# </cfif></cfif></td> </tr> </table> |
|
#2
|
|||
|
|||
|
Code:
<cfoutput> <cfif not StructKeyExists(form, 'operation')> <form action="#GetFileFromPath(cgi.script_name)#" method="post"> <input type="submit" name="operation" value="Start Time"> </form> <cfelse> <cfif form.operation eq "Start Time"> <cfset startTime = Now() /> Start Time: #TimeFormat(startTime, "HH:mm:ss")# <form action="#GetFileFromPath(cgi.script_name)#" method="post"> <input type="hidden" name="startTime" value="#startTime#" /> <input type="submit" name="operation" value="End Time"> </form> <cfelseif form.operation eq "End Time"> <cfset startTime = form.startTime /> <cfset endTime = Now() /> Start Time: #TimeFormat(startTime, "HH:mm:ss")#<br /> End Time: #TimeFormat(endTime, "HH:mm:ss")# </cfif> </cfif> </cfoutput>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Tracking Time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|