Tip: you can modify some code before running
Js date selection box code<html><head><title>Date Selection Box</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body onLoad="fload()" bgcolor="#3366CC"><!--由键关闭当前窗口--><SCRIPT language=JavaScript><!--if (window.Event) document.captureEvents(Event.MOUSEUP); function nocontextmenu() {event.cancelBubble = trueevent.returnValue = false;return false;}function norightclick(e) {if (window.Event) {if (e.which == 2 || e.which == 3)return false;}elseif (event.button == 2 || event.button == 3){event.cancelBubble = trueevent.returnValue = false;window.opener="";window.close();return false;}}document.oncontextmenu = nocontextmenu; // for IE5+document.onmousedown = norightclick; // for all others//--></sCRIPT><!--由键关闭当前窗口--><script Language="JavaScript">Var gdCtrl = new Object (); var goSelectTag = new Array (); var gcGray = "#808080"; var gcToggle = "# ffff00 "; var gcBG = "#99 CCFF"; var previousObject = null; var gdCurDate = new Date (); var giYear = gdCurDate. getFullYear (); var giMonth = gdCurDate. getMonth () + 1; var giDay = gdCurDate. getDate (); var gCalMode = ""; var gCalDefDate = ""; var CAL_MODE_NOBLANK = "2"; function fSetDate (iYear, iMonth, iDay) {// VicPopCal . Style. visibility = "hidden"; if (iYear = 0) & (iMonth = 0) & (iDay = 0) {gdCtrl. value = "";} else {iMonth = iMonth + 100 + ""; iMonth = iMonth. substring (1); iDay = iDay + 100 + ""; iDay = iDay. substring (1); gdCtrl. value = iYear + "-" + iMonth + "-" + iDay;} for (I in goSelectTag) goSelectTag [I]. style. visibility = "visible"; goSelectTag. length = 0; window. returnValue = gdCtrl. value; // alert (gdCtrl. v Alue) window. close ();} function HiddenDiv () {var I; VicPopCal. style. visibility = "hidden"; for (I in goSelectTag) goSelectTag [I]. style. visibility = "visible"; goSelectTag. length = 0;} function fSetSelected (aCell) {var iOffset = 0; var iYear = parseInt (tbSelYear. value); var iMonth = parseInt (tbSelMonth. value); aCell. bgColor = gcBG; with (aCell. children ["cellText"]) {var iDay = parseInt (innerText); if (Color = gcGray) iOffset = (Victor <10 )? -1:1;/*** below temp patch by maxiang ***/if (color = gcGray) {iOffset = (iDay <15 )? 1:-1;}/*** abve temp patch by maxiang ***/iMonth + = iOffset; if (iMonth <1) {iYear --; iMonth = 12 ;} else if (iMonth> 12) {iYear ++; iMonth = 1 ;}} fSetDate (iYear, iMonth, iDay);} function Point (iX, iY) {this. x = iX; this. y = iY;} function fBuildCal (iYear, iMonth) {var aMonth = new Array (); for (I = 1; I <7; I ++) aMonth [I] = new Array (I); var dCalDate = new Date (iYear, iMonth-1, 1); var iDayOfFirst = dCalDate. getDay (); var iDaysInMonth = new Date (iYear, iMonth, 0 ). getDate (); var iOffsetLast = new Date (iYear, iMonth-1, 0 ). getDate ()-iDayOfFirst + 1; var iDate = 1; var iNext = 1; for (d = 0; d <7; d ++) aMonth [1] [d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++; for (w = 2; w < 7; w++) for (d = 0; d < 7; d++)aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++); return aMonth;}function fDrawCal(iYear, iMonth, iCellHeight, sDateTextSize) { var WeekDay = new Array("日","一","二","三","四","五","六"); var styleTD = " bgcolor='"+gcBG+"' bordercolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' ; with (document) {write("<tr>"); For (I = 0; I <7; I ++) write ("<td "+styleTD+" color:#990099' >"+ WeekDay [I] +"</td>"); Write ("</tr>"); For (w = 1; w <7; w ++) {write ("<tr>"); For (d = 0; d <7; d ++) {write ("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>"); Write ("<font id=cellText ><b> </b></font>"); Write ("</td>")} Write ("</tr>") ;}} Function fUpdateCal (iYear, iMonth) {myMonth = fBuildCal (iYear, iMonth); var I = 0; for (w = 0; w <6; w ++) for (d = 0; d <7; d ++) with (cellText [(7 * w) + d]) {Victor = I ++; if (myMonth [w + 1] [d] <0) {color = gcGray; innerText =-myMonth [w + 1] [d];} else {// Modified by maxiang for we need // Saturday displayed in blue font color. // color = (d = 0) | (d = 6 ))? "Red": "black"; if (d = 0) {color = "red";} else if (d = 6) {color = "blue ";} else {color = "black" ;}// End of above maxianginnerText = myMonth [w + 1] [d] ;}} function fSetYearMon (iYear, iMon) {tbSelMonth. options [iMon-1]. selected = true; for (I = 0; I <tbSelYear. length; I ++) if (tbSelYear. options [I]. value = iYear) tbSelYear. options [I]. selected = true; fUpdateCal (iYear, iMon);} function fPrevMonth () {var iMon = tbSelMonth. value; var iYear = tbSelYear. value; if (-- iMon <1) {iMon = 12; iYear --;} fSetYearMon (iYear, iMon);} function fNextMonth () {var iMon = tbSelMonth. value; var iYear = tbSelYear. value; if (++ iMon> 12) {iMon = 1; iYear ++;} fSetYearMon (iYear, iMon);} function fToggleTags () {with (document. all. tags ("SELECT") {for (I = 0; I<length; i++) if ((item(i).Victor!="Won")&&fTagInBound(item(i))){ item(i).style.visibility = "hidden"; goSelectTag[goSelectTag.length] = item(i); } }}function fTagInBound(aTag){ with (VicPopCal.style){ var l = parseInt(left); var t = parseInt(top); var r = l+parseInt(width); var b = t+parseInt(height);var ptLT = fGetXY(aTag);return !((ptLT.x>R) | (ptLT. x + aTag. offsetWidth<l)||(ptLT.y>B) | (ptLT. y + aTag. offsetHeight<t)); }}function fGetXY(aTag){ var oTmp = aTag; var pt = new Point(0,0); do { pt.x += oTmp.offsetLeft; pt.y += oTmp.offsetTop; oTmp = oTmp.offsetParent; } while(oTmp.tagName!="BODY"); return pt;}// Main: popCtrl is the widget beyond which you want this calendar to appear;// dateCtrl is the widget into which you want to put the selected date.// i.e.: <input type="text" name="dc" readonly><INPUT type="button" value="V" onclick="fPopCalendar(dc,dc);return false">Function fPopUpCalendarDlg (ctrlobj) // The calendar {showx = event is displayed. screenX-event. offsetX-4-210; // + deltaX; showy = event. screenY-event. offsetY + 18; // + deltaY; newWINwidth = 210 + 4 + 18; retval = window. showModalDialog ("pub_CalendarDlg.asp", "", "dialogWidth: 172px; dialogHeight: 210px; dialogLeft:" + showx + "px; dialogTop:" + showy + "px; status: no; directories: yes; scrollbars: no; Resizable = no; "); if (retv Al! = Null) {ctrlobj. value = retval;} else {// alert ("canceled") ;}} function fPopCalendar (popCtrl, dateCtrl, mode, defDate) {gCalMode = mode; gCalDefDate = defDate; if (popCtrl = previousObject) {if (VicPopCal. style. visibility = "visible") {// HiddenDiv (); return true ;}} previousObject = popCtrl; gdCtrl = dateCtrl; fSetYearMon (giYear, giMonth ); var point = fGetXY (popCtrl); if (gCalMode = CAL_MODE_NOBLANK) {document. all. CAL_ B _BLANK.style.visibility = "hidden";} else {document. all. CAL_ B _BLANK.style.visibility = "visible";} with (VicPopCal. style) {left = point. x; top = point. y + popCtrl. offsetHeight; width = VicPopCal. offsetWidth; height = VicPopCal. offsetHeight; fToggleTags (point); visibility = 'visible ';} var gMonths = new Array ("January", "February", "March", "April ", "May", "June", "July", "August", "September", "October", "November", "December"); with (document) {write ("<Div id='VicPopCal' >"); Write ("<table border='0' bgcolor='#3366CC'>"); Write ("<TR>"); Write ("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' onClick='fPrevMonth()'>"); Write ("<SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>"); For (I = 2000; I <2021; I ++) write ("<OPTION value='"+i+"'>"+ I +" year</oPTION>"); Write ("</sELECT>"); Write ("<select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>"); For (I = 0; I <12; I ++) write ("<option value='"+(i+1)+"'>"+ GMonths [I] +"</option>"); Write ("</sELECT>"); Write ("<input type='button' name='PrevMonth' value='>'Style = 'height: 20; width: 20; FONT: bold 'onclick = 'fnextmonth () '> "); write ("</td>"); Write ("</tR><TR>"); Write ("<td align='center'>"); Write ("<DIV ><table width='100%' border='0'>"); FDrawCal (giYear, giMonth, 8, '12'); write ("</table></dIV>"); Write ("</td>"); Write ("</tR><TR><TD align='center'>"); Write ("<TABLE width='100%'><TR><TD align='center'>"); Write ("<B ID="CAL_B_BLANK" +gcBG+"; visibility:visible; cursor:hand; font-size:11px' onclick='fSetDate(0,0,0)' onMouseOver='this.style.color=gcToggle' onMouseOut='this.style.color=gcBG'>清空</b>");write("</td><td algin='center'>");write("<B +gcBG+";cursor:hand; font-size:11px' onclick='fSetDate(giYear,giMonth,giDay)' onMouseOver='this.style.color=gcToggle' onMouseOut='this.style.color=gcBG'>Select: "+ giYear +"/"+ giMonth +"/"+ giDay +"</b>"); Write ("</td></tr></table>"); Write ("</tD></tR>"); Write ("</tABLE></div>");}</script><script>function fload(){fPopCalendar(document.all.txt1, document.all.txt1);}function fkeydown(){if(event.keyCode==27){event.returnValue = null;window.returnValue = null;window.close();}}document.onkeydown=fkeydown;</script><input type=text id="txt1" ></body></html>
Tip: you can modify some code before running