How to initiate a calendar to show a certain month?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
testuser
User
Posts: 24

How to initiate a calendar to show a certain month?

Post 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!


arbei
User
Posts: 9284

Post 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.


mobhar
User
Posts: 11660

Post 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


testuser
User
Posts: 24

Post by testuser »

Thanks so much! It works!


Post Reply