0

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

Jason
  • 1
  • 1
  • 1

3 Answers3

1

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.

Cesar
  • 31
  • 3
0

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

bcolin
  • 438
  • 3
  • 6
  • I noticed that for the syntax error, but the i get undefined see link below http://s21.postimage.org/au2shmbs7/js_Date_Pick_Undefined.png Thanks for help so far – Jason Mar 19 '13 at 09:50
0

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() {};
    }
};
Mikaere
  • 75
  • 1
  • 6