How to initiate a calendar to show a certain month?
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!
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!
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.
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
Thanks so much! It works!