DhtmlxCalendar setting date doesn't work when hidden

Hi,

I attached the calendar to an input box. Now when people click in the calendar, I want it to show todays date + one month. This is the code I use:

<div style="position:relative;height:250px;">
   <input type="text" id="datTerug" value="" />
</div>

<script type="text/javascript">
dhtmlXCalendarObject.prototype.langData["nl"] = {
			dateFormat: "%d/%m/%Y",
			monthesFNames: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
			monthesSNames: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
			daysFNames: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"],
			daysSNames: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za"],
			weekstart: 1
		}
		var now = new Date();
		var mnd;
		var datum;

		if (now.getMonth() == 11){//11=december
			mnd = "/01/";
			datum = (now.getYear() + 1) + mnd + now.getDate();
		}
		else{
			mnd = now.getMonth() + 2; //current month: +1, next month: +2
			if (mnd<10){
				mnd="0"+mnd;
			}
			datum = now.getYear() + "-" + mnd + "-" + now.getDate();
		}

		var myCalendar;
		myCalendar = new dhtmlXCalendarObject(["datTerug"]);
		myCalendar.hideTime();
		myCalendar.setDate(datum);
		myCalendar.loadUserLanguage("nl");
</script>

If I click in the field datTerug, the calendar shows the date of today, but in the code I said that it should take the date of today + 1 month.

Any suggestions?

Hi

[code]var myCalendar = new dhtmlXCalendarObject(…);

// replace native show func with custom
myCalendar._show2 = myCalendar._show;
myCalendar._show = function(a,b){
// keep native func calls
this._show2(a,b);
// detect date and add one month
var t = this.getDate();
t.setMonth(t.getMonth()+1);
if (…) {
// if you need to keep current date but only show next month
this._drawMonth(t);
} else {
// if you need to show current date selected in a next month
this.setDate(t);
}
}[/code]

Do I need to exit the .js file? Or do I need to put the code directly in my html-/php-code?
Because it won’t work for me :confused:

Ok there was an error in my code, it works, thx :slight_smile: