|
|
Subject:
coldfusion/javascript question
Category: Computers > Programming Asked by: bigsticks-ga List Price: $5.00 |
Posted:
28 May 2004 16:18 PDT
Expires: 27 Jun 2004 16:18 PDT Question ID: 353364 |
I'm working a coldfusion application. I am a mainframe programmer and pretty new to coldfusion. I will be accepting form data in the form of select boxes to add an employee's start and stop times to a sqlserver database (e.g., 08:00 to 05:00 P.M.). There will be 3 select boxes: start time, end time, AM or PM. How do I take this data and move the individual values to a sqlserver timestamp value? Also, vice versa: move from database to individual select boxes to display. Please provide sample code. Thanks! |
|
There is no answer at this time. |
|
Subject:
Re: coldfusion/javascript question
From: lucos-ga on 29 May 2004 06:33 PDT |
Over on the Coldfusion forums if you do a search for Javascript and Coldfusion you get two sorts of answers. The first is to use something called WDDX or something (Haven't got a clue how that works). The second is to use the input from the forms, use javascript to process them, input them back in to those forms and submit the form to a coldfusion page. That might seem a bit long winded so the WDDX thing might be worth a look up. |
Subject:
Re: coldfusion/javascript question
From: coldfusion1-ga on 04 Jun 2004 11:58 PDT |
Hey man, if you got ColdFusion questions, just post'em here http://www.macromedia.com/cfusion/webforums/forum/index.cfm?forumid=1 I'll go ahead and answer this one for you, this has nothing to do with WDDX. Since you have that AM PM box your going to have to do some extra work. To move the data to the sqlserver: <cfif FORM.AM_PM EQ "PM"> <cfset FORM.hour = FORM.hour + 12> </cfif> then use the CreateOBDCTime function UPDATE your_table SET your_timestamp_column = #CreateOBDCTime (FORM.hour,FORM.minute)# to more the data from the server: use the hour() and minute() functions SELECT your_timestamp_column FROM your_table #hour(your_timestamp_column MOD 12)# #min(your_timestamp_column)# <cfif hour(your_timestamp_column) GT 12> PM <cfelse> AM </cfif> |
Subject:
Re: coldfusion/javascript question
From: mr_nil-ga on 27 Jun 2004 09:43 PDT |
The second answer is close, but not quite. Before you pass the date to CreateODBCTime() to pass it into your database, you need to create a valid date. Also, the best way to display times is to use the TimeFormat() function. <cfscript> if (form.hour LT 12 AND form.am_pm EQ 'PM') form.hour = form.hour +12; thisTime = CreateTime(form.hour,form.minute,0); </cfscript> <cfquery name="UpdateTime" datasource="yourdsn"> UPDATE your_table SET your_timestamp_column = #CreateOBDCTime(thisTime)# </cfquery> <cfoutput>#TimeFormat(thisTime,"hh:mm tt")</cfoutput> HTH. |
Subject:
Re: coldfusion/javascript question
From: mr_nil-ga on 27 Jun 2004 09:59 PDT |
To add to that to get your dates back out into the select boxes <cfquery name="timequery" datasource="yourdsn"> SELECT your_timestamp_column FROM your_table WHERE keyfield = 123 </cfquery> <cfset thisHour = hour(timequery.your_timestamp_column)> <cfset thisMinute = minute(timequery.your_timestamp_column)> <cfset thisAM_PM = "AM"> <cfif this Hour GT 12> <cfset thisHour = thisHour-12> <cfset thisAM_PM = "PM"> </cfif> <form action="actionpage.cfm" method="post"> <select name="hour"> <cfloop index="i" from="1" to="12"> <cfoutput><option value="#i#" #IIF(thisHour EQ i,DE('selected'),DE(''))#>#i#</option></cfoutput> </cfloop> </select> <select name="minute"> <cfloop index="i" from="0" to="59"> <cfoutput><option value="#i#" #IIF(thisMinute EQ i,DE('selected'),DE(''))#>#i#</option></cfoutput> </cfloop> </select> <select name="am_pm"> <cfoutput> <option value="AM" #IIF(thisAM_PM EQ 'AM',DE('selected'),DE(''))#>AM</option> <option value="PM" #IIF(thisAM_PM EQ 'PM',DE('selected'),DE(''))#>pM</option> </cfoutput> </select> </form> I recommend that you take a look at http://livedocs.macromedia.com/ as a good online tag and function reference and purchase yourself a good book eg. Mastering CFMX |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |