• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

bind

Explorer ,
Jul 13, 2012 Jul 13, 2012

Copy link to clipboard

Copied

I have two text boxes

1.  First text box is defaulted to the curent date + 5 business days. 

2.  When i pick the date from the second text box, I want the date in the fisrt text box = date in second text box + 5 business days.

The code i have below is currently working fine but the fist fidn't added 5 business days because i don't know how to add into it from txt2.

How can I accomplish it?

<!---cfm--->

<cfparam name="currentdate" default="#businessDaysAdd(now(),5))#">

<cfform name="fform">

   txt1: <cfinput type="datefield" value="#dateformat(current, "mm/dd/yyyy")#" name="txt1" bind="cfc:app.home.cfc.bu.getfinaldate({txt2@change})">

   txt2: <cfinput type="datefield" name="txt2" value="">

</cfform>

<!---cfc--->

</cfcomponent>

<cffunction name="getfinaldate" access="remote">

        <cfargument name="txt2">

         <cfreturn "#arguments.txt2#">

    </cffunction>

</cfcomponent>

Thanks

TOPICS
Getting started

Views

754

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2012 Jul 14, 2012

Copy link to clipboard

Copied

In your cfc, use parsedate to convert the text to a date, then use dateadd to add the five days and dateformat to convert it back to a string. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2012 Jul 15, 2012

Copy link to clipboard

Copied

LATEST

Note you have a typo: 2 closing component tags. In any case, the following should work

<cfform name="fform">

<!--- Set bindOnload to yes, making the bind to take effect the moment the page is loaded. --->

<cfinput type="datefield"  name="txt1" bind="cfc:app.home.cfc.bu.getFinalDate({txt2})" bindOnload="yes">

<cfinput type="datefield" name="txt2">

</cfform>

bu.cfc

<cfcomponent>

<cffunction name="getFinalDate" access="remote" returntype="string">

        <cfargument name="dateArg">

        <!--- If argument undefined or not a date, then default to date of today --->

        <cfif (not isDefined("arguments.dateArg")) or (not isDate(arguments.dateArg))>

            <cfset var dt = now()>

        <cfelse>

            <cfset var dt = parseDateTime(arguments.dateArg)>

        </cfif>

        <!--- Add 5 days--->

        <cfset var updatedDt = dateAdd("d",5,dt)>

        <!--- Format --->

        <cfset var formattedDt = dateformat(updatedDt, "mm/dd/yyyy")>

         <cfreturn formattedDt>

</cffunction>

</cfcomponent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation