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

Can cfdiv value be placed in another variable

Explorer ,
Nov 27, 2018 Nov 27, 2018

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

656
Translate
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 ,
Nov 27, 2018 Nov 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,

^ _ ^

Translate
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
Explorer ,
Nov 27, 2018 Nov 27, 2018

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

Mike

Translate
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 ,
Nov 28, 2018 Nov 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,

^ _ ^

Translate
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
Explorer ,
Nov 28, 2018 Nov 28, 2018

Below is the javascript..

The code does not display the popup window.

If the var days = (DateDiff.inDays(d1, d2)); is commented out, the popup window appears.

<script type="text/javascript">


function fnErrorCheck()

{


var d1 = document.getElementById('StartDate').value;

var d2 = document.getElementById('EndDate').value;


var days = DateDiff.inDays(d1, d2);


alert("The" + d1 + d2 )

return false


}

</script>

Translate
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 ,
Nov 28, 2018 Nov 28, 2018

Use DevTools (F12 in FF and IE and Chrome) and use the console tab.  This should present the error message.

What is DateDiff.inDays?  Where is that defined?  Is that another function of yours?

V/r,

^ _ ^

Translate
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 ,
Nov 28, 2018 Nov 28, 2018
LATEST

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
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