A recently transformed multiple-choice calendar plug-in that has passed the compatibility test.

Source: Internet
Author: User

First:

In fact, if you change from the previous month to the next month or last month, the current selection will still be saved and displayed as shown in the beginning.

This batch select date can be used in some scenarios, such as planning or querying.

First, declare: This is an adapted multi-Choice Date plug-in. It turns out to be a common but practical calendar control. Thanks again to the original author.

A class is designed. The main idea is to: (block the code that disappears after selection, remember the selected and colored date, and display the date that was previously remembered based on the current data in the Drawing Process of the date control area .)

 

Function $2 (ID) {return document. getelementbyid (ID);} function selectdatecache () {This. cache = []; // The selected and colored date is stored in this array this. add = function (sdate) {If (! This. exist (sdate) This. cache. push (sdate) ;}; this. clear = function () {This. cache. splice (0, this. cache. length) ;}; this. remove = function (sdate) {for (VAR I = 0, L = This. cache. length; I <L; I ++) {If (this. cache [I] = sdate) {This. cache. splice (I, 1); break ;}}; this. exist = function (sdate) {for (VAR I = 0, L = This. cache. length; I <L; I ++) {If (this. cache [I] = sdate) {return true ;}} return false ;}; this. getrelatecontrolidbydate = function (sdate) {var SDAY = '', smonth ='', syear = ''; var stemp = sdate. split ('-'); If (stemp [1]. substr (0, 1) = '0') {smonth = stemp [1]. substr (1);} else {smonth = stemp [1];} smonth = (parseint (smonth + '')-1) +" "; if (stemp [2]. substr (0, 1) = '0') {SDAY = stemp [2]. substr (1, 1);} else {SDAY = stemp [2];} syear = stemp [0]; vaR controlid = "day-" + SDAY + "-" + smonth + "-" + syear; return controlid ;}; this. getdatefromcontrolid = function (scontrolid) {// day-16-1-2013 var stemp = scontrolid. split ('-'); If (stemp [1]. length = 1) stemp [1] = '0' + stemp [1]; stemp [2] = (parseint (stemp [2]) + 1) + ""; if (stemp [2]. length = 1) stemp [2] = '0' + stemp [2]; return stemp [3] + '-' + stemp [2] + '-' + stemp [1] ;};} var aselectcontroller = new selectdatecache ();

 

Code of the front-end page:

<HTML xmlns = "http://www.w3.org/1999/xhtml"> 

 

In addition, I have uploaded the referenced JS and CSS files to the files in the garden, but I have been searching for them for a long time, I don't know how to display the resources in the files in blog management in some way in the current document.

It's a bit cold outside, and I feel a little sleepy ..

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.