Skip to main content
Participating Frequently
January 18, 2013
Question

Can't get cfcalendar control work client side to selectedDate with JavaScript

  • January 18, 2013
  • 1 reply
  • 572 views

I am not sure why this is happening, I have a function where I am passing a date value, and I've seen it while displaying it and in alerts.  So it comes across such as this 01/22/2013.

I am trying to get the cfCalendar control I have to select the date but I can't seem to reference the property...

Simple control defined in the form:

<cfcalendar name="calDisplay" 

        selectedDate="#SelDate#"     

        mask="mmm dd, yyyy"

        dayNames="Su,M,Tu,W,Th,Fr,Sa"

        monthNames="JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC"

        style="rollOverColor:##FF0000"        

        width="150" height="150" id="calDisplay"  >

here's the javascript the parameter is being passed correctly this I have verified:

function edit_Item(st_Date)

{

  document.getElementById('calDisplay').value = stDate;  //doesn't work

     document.getElementById('calDisplay').value = Date(stDate); //doesn't work

document.getElementById('calDisplay').selectedDate= stDate; //doesn't work

document.getElementById('calDisplay').select(stDate);  //doesn't work

}

This has to be a real simple thing to do I am sure it's 2 lines of code, but the calendar will not highlight the date I am passing and select it.  I am not sure what to do.

If anyone has any suggestions, please let me know.  I am trying to do this client side with the control I hope this is possible.

Thanks,

- E

    This topic has been closed for replies.

    1 reply

    Inspiring
    January 18, 2013

    cfcalendar produces a flash object which is not accessible by javascript.

    Participating Frequently
    January 22, 2013

    well this is no good... anyone suggest a similar calendar control I could use.. that does what I need to do?

    I am trying a simple coldfusion cfinput datefield instead, and this is sort of working since I can set the field to the date using javascript.

    The only problem is that if the calendar is still open, It wont highlight the correct date.  If I close it and reopen it then yeah sure it will show it.

    Is this also not possible with a cfinupt datefield?  If I can get it to highlight the correct date, or simply just close the calendar (the little X action) but I am not getting this going either (It's either not possible or I am calling the wrong properties or method.).

    Any other info would be useful.  Thanks!