Page 1 of 1

How to initiate a calendar to show a certain month?

Posted: Tue Feb 21, 2017 11:44 pm
by testuser

Hi there,

How can I initiate a calendar to show a certain month on one web page? e.g. I need to set the calendar to show June 2017 when the calendar shows up.

Thanks!


Re: How to initiate a calendar to show a certain month

Posted: Thu Feb 23, 2017 6:08 pm
by arbei

Use demo project Order table field OrderDate as an example, you can add below code in the startup script of add page to change the initial date of the calendar.

$(function(){
var btn = $("#el_Orders_OrderDate").find("button")[0]; // Get the calendar button object.
var fn = btn.onclick; // save the click event in variable fn.
btn.onclick = null; // unsubscribe the origial onclick event to prevent call the origial function twice.

$("#el_Orders_OrderDate").find("button").on("click", function(e, args){  //subscribe the onclick event.
	fn(); //call the origial function and the calendar will saved into "window.calendar".
	window.calendar.setDate(new Date("2016/01/01"));  // get the calendar object and use setDate function to change the initial date.
});	

});

You may need to check is there any value in the input before you change the date of the calendar.

Read the document of jsCalendar for more information.


Re: How to initiate a calendar to show a certain month

Posted: Thu Feb 23, 2017 6:21 pm
by mobhar

Please note that the element id is case-sensitive. In the demo project, the table name is in lowercase. As we can see, from the "demo2017.sql" file, the table name of "orders" is in lowercase.

This code:
el_Orders_OrderDate

should be:
el_orders_OrderDate


Re: How to initiate a calendar to show a certain month

Posted: Thu Mar 02, 2017 5:47 am
by testuser

Thanks so much! It works!