UPDATE:
Thank you for all your advice yesterday I was able to figure it out and I
want to share the solution with everyone.
I tried using the Actionscript outside the cfform with cfsavecontent and
inside the form with cfformitem and the only one that works well for me is
the cfformitem type=script.
Below is the code that actually works.
---------------------------------------------------------
<cfformitem type="script">
function dayCount(){
var start:Date = leavestartdate.selectedDate;
var end:Date = leaveenddate.selectedDate;
if(start != undefined && end != undefined){
LEAVEDAYS.text = (end - start)/(3600*24*1000);
}
}
</cfformitem>
<cfinput label="Date:" name="leavestartdate" validate="date"
type="datefield" value="#LEAVESTARTDATE#" width="100" />
<cfinput label="Date:" name="leaveenddate" validate="date"
type="datefield" value="#LEAVEENDDATE#" width="100"
onChange="{dayCount();}" />
<cfinput label="Total Days:" type="text" name="LEAVEDAYS"
value="#LEAVEDAYS#" width="45" />
------------------------------------------------------------
The reason that the leavedays input field defines a value is because the
form is a reusable form. But here you have it code that works with a
cfform flash formatted and can update a field without updating the page.
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Seth Bienek
Sent: Thursday, August 09, 2007 12:39 PM
To: [email protected]
Subject: [houcfug] Re: cfform.bind and datediff
Hey Ernie,
What kind of error are you getting? Anything?
You do not necessarily need to do a bind. Just set the value of the
control
explicitly from your script.
<cfformitem type="script">
function clicked(){
var date1 ate = getDateFromString(leavestartdate.text);
var date2 ate = getDateFromString(leaveenddate.text);
if(leavestartdate.length != 0 && leaveenddate.length != 0){
_root.leavedays.text = (date1 - date2)/(3600*24*1000);
}
}
</cfformitem>
...
<cfinput label="Total Days:" type="text" name="leavedays"
value="#LEAVEDAYS#" width="45"/>
Also, don't forget, ActionScript is case sensetive.
Take Care,
Seth
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Thursday, August 09, 2007 11:40 AM
To: [email protected]
Subject: [houcfug] cfform.bind and datediff
Hi All,
I hope someone can help me with this, I am creating a form where the user
can select a start date and an end date in a cfform in a flash format.
I have been doing a lot of research trying to figure out this and I
haven't come up with something that will work in a bind to the cfinput.
Example:
<cfform name....>
<cfformitem type="script">
function clicked(){
var date1 ate = getDateFromString(leavestartdate.text);
var date2 ate = getDateFromString(leaveenddate.text);
if(leavestartdate.length != 0 && leaveenddate.length != 0){
leavedays.text = (date1 - date2)/(3600*24*1000);
}
}
</cfformitem>
<cfformgroup type="hdividedbox">
<cfformgroup type="page">
<cfformitem type="text"
style="font-weight:bold">Date & Time of Depature.</cfformitem>
<cfformgroup type="horizontal">
<cfinput label="Date:"
name="leavestartdate" validate="date" type="datefield"
value="#LEAVESTARTDATE#" width="100" />
<cfinput label="Time:"
name="leavestarttime" validate="time" type="text" value="#LEAVESTARTTIME#"
width="75" />
</cfformgroup>
</cfformgroup>
<cfformgroup type="page">
<cfformitem type="text"
style="font-weight:bold">Date & Time of Return.</cfformitem>
<cfformgroup type="horizontal">
<cfinput label="Date:" name="leaveenddate"
validate="date" type="datefield" value="#LEAVEENDDATE#" width="100" />
<cfinput label="Time:" name="leaveendtime"
validate="time" type="text" value="#LEAVEENDTIME#" width="75" />
</cfformgroup>
</cfformgroup>
</cfformgroup>
<cfinput label="Total Days:" type="text" name="LEAVEDAYS"
value="#LEAVEDAYS#" width="45" bind="{clicked();}" />
</cfform>
Thanks in advance
Ernie Pena
U.T. M. D. Anderson Cancer Center.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Houston ColdFusion
Users' Group" discussion list.
To unsubscribe, send email to [EMAIL PROTECTED]
For more options, visit http://groups.google.com/group/houcfug?hl=en
-~----------~----~----~----~------~----~------~--~---