Skip to main content
Inspiring
November 27, 2018
Question

Can cfdiv value be placed in another variable

  • November 27, 2018
  • 2 replies
  • 724 views

Hi,

I have the following cfdiv that works just fine.

Is there away to capture the value in DaysAvailable when it comes back and place it in another variable?

<cfdiv name="DaysAvailable" bindonload="no" bind="cfc:#this.LOC#.common.hcbsservicemath.getDaysAvailable({StartDate@change},{EndDate@change})">

Thanks,

Mike

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    November 29, 2018

    UserCold9 wrote:

    Is there away to capture the value in DaysAvailable when it comes back and place it in another variable?

    <cfdiv name="DaysAvailable" bindonload="no" bind="cfc:#this.LOC#.common.hcbsservicemath.getDaysAvailable({StartDate@change},{EndDate@change })">

    A few things:

    1) the name attribute does not exist.

    2) the variables you're dealing with here are Javascript, hence known only to the browser. The value you wish to have comes from ColdFusion.

    3) therefore, one way you could do it is as follows

    <!--- store the value in a session--->

    <cffunction name="getDaysAvailable">

    ...

    ...

    <cfset session.daysAvailable = daysAvailable>

    <cfreturn daysAvailable>

    </cffunction>

    <!--- obtain the value in the cfdiv page (after the cfdiv tag, of course)--->

    <cfset daysAvailable = session.daysAvailable>

    WolfShade
    Legend
    November 27, 2018

    I've never worked with CFDIV (that I can remember, anyway), so don't really have experience with what you are requesting.

    However, it's my understanding that CFDIV will use Javascript to insert a DIV at the location where the CFDIV tag is used, and gives said DIV the name as set in the CFDIV tag.  Based upon this, it should be possible (I've never tested it) to use JavaScript to detect a change in the value of the div, grab the new value, and use AJaX to POST that value to a function within a CFC that can assign said value to a variable.  Probably in the session scope would be best.

    Or I'm way overthinking this. 

    HTH,

    ^ _ ^

    userCold9Author
    Inspiring
    November 27, 2018

    I tried to use javascript and the page did not like it.

    Mike

    WolfShade
    Legend
    November 28, 2018

    Did you place your code at the bottom of the document, just before the closing </body> tag?  Are you using jQuery, or just plain vanilla JavaScript?  What error messages appeared in console, if any?  Could you post your code?

    V/r,

    ^ _ ^