Skip to main content
Inspiring
Nov 27, 2018 9:39 PM UTC
Question

Can cfdiv value be placed in another variable

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 is closed to new replies. Start a new post to keep the conversation going.

    6 replies

    BKBK
    Community Expert
    Community Expert
    Nov 29, 2018 6:01 AM UTC

    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>

    Translate
    WolfShade
    Legend
    Nov 27, 2018 10:29 PM UTC

    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,

    ^ _ ^

    Translate
    userCold9Author
    Inspiring
    Nov 27, 2018 10:42 PM UTC

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

    Mike

    Translate
    WolfShade
    Legend
    Nov 28, 2018 4:04 PM UTC

    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,

    ^ _ ^

    Translate