Instructions for use:
ProgramRelatively simple,CodeThere are instructions in this section. Here we will talk about how to use it.
First, instantiate a calendar and set parameters.
Parameter description:
Year: Year to be displayed
Month: The month to be displayed.
Selectday: select a date
Onselectday: triggered on the selected date
Ontoday: triggered on the current day
Onfinish: triggered after the calendar is painted
Generally, selectday is set to the selected date, and a function is set in onselectday to set the style of the date,
For example, set selectday In the instance to "10" of this month and "onselect" in the style of that day:Copy codeThe Code is as follows: selectday: new date (). setdate (10 ),
Onselectday: function (o) {o. classname = "onselect ";},
Ontoday is used to set the style of today's date,
For example, in the instance, set the date style to ontoday:
Ontoday: function (o) {o. classname = "ontoday ";},
In onfinish, you can set the calendar program.
You can use this. year and this. Month to obtain the year and month displayed in the current calendar.
The date with data is also set here. For example, the instance contains a list of date with data for the current month, and then the corresponding date is set according to the list:Copy codeThe Code is as follows: var flag = [10, 15, 20];
For (VAR I = 0, Len = flag. length; I <Len; I ++ ){
This. days [flag [I]. innerhtml = "<a href = 'javascript: void (0); 'onclick = \" alert ('date is: "+ this. year + "/" + this. month + "/" + flag [I] + "'); Return false; \"> "+ flag [I] +" </a> ";
}
The date list is fixed in the instance. In actual application, you can obtain the corresponding date list based on the year month,
We recommend that you use ajax to obtain the year and month.
There are two useful methods in the program: premonth (show the previous month) and nextmonth (show the next month ).
Test code:Xmlns = "http://www.w3.org/1999/xhtml">
<>
2008Year8Month