jsDatePick - Using a Selected Date

Using the jsDatePick Full JQuery example i am unable to get the calender to load with a specified date selected, i recieve either undifined message or syntax errors

The full code can be downloaded from JsDatePick

The Code they supply

g_globalObject2 = new JsDatePick({
useMode:1,
isStripped:false,
target:"div4_example",
cellColorScheme:"beige"
/*          
selectedDate:{
day:16,
month:3,
year:2013
},
yearsRange:[1978,2020],
limitToToday:false,
dateFormat:"%m-%d-%Y",
imgPath:"img/",
weekStartDay:1*/
});

If i then un comment the slected date part i get either undifined on the calendar once it loads or it fails to load with a syntax issue

Can anyone help?

Thanks

Answers:

Answer

I had the same problem and found the following solution from a post by this German fellow (http://www.viathinksoft.de/?page=news&id=184). The post is in German and if you translate it in English, it messes up the code he provided so copy the code first or you can copy below. Here's his fix, you need to modify "jsDatePick.full.1.3.js" script, function "setConfiguration" with the following:

 this.selectedDayObject = {};
 this.flag_DayMarkedBeforeRepopulation = false;
 this.flag_aDayWasSelected = false;
 this.lastMarkedDayObject = null;

 if (!this.oConfiguration.selectedDate){
      this.currentYear      = this.oCurrentDay.year;
      this.currentMonth     = this.oCurrentDay.month;
      this.currentDay          = this.oCurrentDay.day;
 } else {
      this.currentYear      = this.oConfiguration.selectedDate.year;
      this.currentMonth     = this.oConfiguration.selectedDate.month;
      this.currentDay          = this.oConfiguration.selectedDate.day;
      this.selectedDayObject = this.oConfiguration.selectedDate;
      this.flag_aDayWasSelected = true;                                   
 }

Basically, he added the "else" condition and actions to the code.

In your HTML, you need to use "jsDatePick.full.1.3.js".

Hope this helps.

Answer

When uncommenting the selected date part, did you add a , at the end of cellColorScheme:"beige" ? If no, you'll get a syntax error.

Answer

I had the same problem, and mine was on an edit page so I need to set for the record being edited in the jsDatePick date and have that appear in the target textbox (I couldn't just set the date in the textbox, this caused the NaN issue in the first place). So my resolution is an extension of Cesar's one:

this.selectedDayObject = {};  
this.flag_DayMarkedBeforeRepopulation = false;  
this.flag_aDayWasSelected = false;  
this.lastMarkedDayObject = null;


 if (!this.oConfiguration.selectedDate){
      this.currentYear      = this.oCurrentDay.year;
      this.currentMonth     = this.oCurrentDay.month;
      this.currentDay          = this.oCurrentDay.day;  } else {
      this.currentYear      = this.oConfiguration.selectedDate.year;
      this.currentMonth     = this.oConfiguration.selectedDate.month;
      this.currentDay          = this.oConfiguration.selectedDate.day;
      this.selectedDayObject = this.oConfiguration.selectedDate;
      this.flag_aDayWasSelected = true; 
      this.populateFieldWithSelectedDate();
}

This causes an issue in the closeCalendar function, which needs to be changed to:

JsDatePick.prototype.closeCalendar = function () {
    if (this.JsDatePickBox) {
        this.JsDatePickBox.style.display = "none";
        document.onclick = function() {};
    }
};

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.