|
I've been informed that if you copy and paste the code that I sent, that it will not work. If you delete the carriage return in the alert() function after " days from now. it should run just fine. I guess my email client was trying to help.
Robert
>>> "Robert Moss" <[EMAIL PROTECTED]> 8/24/2006 6:47 pm >>> I think your problem is that you are using coldfusion functions in your actionscript. I do not believe DateDiff is an actionscript function. I've created the following and I think it does what you are asking, but it isn't the cleanest. The problem is I've had to use an invisible datefield so that I could use today's date in the actionscript function. The approprate way in actionscript would be to just use: var todaysDate:Date = new Date(); but since you can not use the new keyword in flash forms, using an invisible datefield was my only workaround. You might also want to consider using flash remoting to send the selected date to coldfusion and then do your datediff with out having to actually leave the page. Anyway, check out the following code, it might start you in the right direction if nothing else.
<cfform name="myForm" format="flash" width="780" skin="haloorange" >
<cfformitem type="script"> public function checkShipDateTest():Void{ var millisecondsBtwDates = shipdate.selectedDate - todaysDate.selectedDate; var secondsBtwDates = Math.floor(millisecondsBtwDates/1000); var minutesBtwDates = Math.floor(secondsBtwDates/60); var hoursBtwDates = Math.floor(minutesBtwDates/60); var daysBtwDates = Math.floor(hoursBtwDates/24); var yearsBtwDates = Math.floor(daysBtwDates/365); var monthsBtwDates = Math.floor(daysBtwDates/365*12); if (daysBtwDates > 30) { alert("Your Ship Date is " + daysBtwDates + " days from now. Please choose a date within 30 days or resubmit at a later time.", "Warning", mx.controls.Alert.CANCEL ); submit.enabled = false; }else{ submit.enabled = true; } } </cfformitem> <cfinput type="datefield" name="shipdate" width="125" label="Ship Date" tooltip="Choose Date" mask="YYYY-MM-DD" > <cfinput type="datefield" name="todaysDate" visible="no" value="#now()#" > <cfinput type="submit" name="submit" value="Submit" > </cfform> Robert
>>> "Mike Sumner" <[EMAIL PROTECTED]> 8/24/2006 9:53 am >>> I am using a flash form and I want to check if a date selected is greater than 30 days from now. I can check it on the action page, but I would like to check it after they select the date. I have tried to use examples from AS Fusion but just can't seem to get the syntax correct. The form will not load.
<cfsavecontent variable="checkShipDate">
var shipdate = shipdate.text; if (DateDiff('D',Now(),shipdate) > 30) { alert("Your Ship Date is more than 30 days from now. Please choose a date within 30 day or resubmit at a later time.", "Warning", mx.controls.Alert.OK ); } </cfsavecontent>--->
the name of the form is myform
here is the cfinput <cfinput type="datefield" name="shipdate" width="125" label="Ship Date" tooltip="Choose Date" mask="YYYY-MM-DD" >
as a bonus if I could stop them from proceeding until they choose a date less than 30 away would be great not just a warning box. I will check for that at the action page.
Thanks in advance for any suggestions.
Mike Sumner ** Confidentiality Notice: This e-mail and any files transmitted with it are confidential to the extent permitted by law and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message and destroy all copies. ** ** Confidentiality Notice: This e-mail and any files transmitted with it are confidential to the extent permitted by law and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message and destroy all copies. ** |
_______________________________________________ Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ http://www.mail-archive.com/list%40dfwcfug.org/ DFWCFUG Sponsors: www.HostMySite.com www.teksystems.com/
