////////////////////////////// // UncCalendar 1.0 // // Author: Zhong@UNC // // E-mail: zhong@uncnet.com // // 06/01/2004 // ////////////////////////////// function Add0(Num) { var Temp=Num; if (parseInt(Num)<10){ Temp="0"+Num } return Temp } function UncCalendar (sName, sDate) { ///////////////////////////////////////////////////////////////////////// //定义UncCalendar对象的属性并赋默认值。 //inputValue属性的值为"today"时表示(客户机)当前日期。 //直接在这里把默认值修改成你想要的,使用时你就什么也不用设置了。 this.inputName = sName || "uncDate"; this.inputValue = sDate || ""; this.inputSize = 10; this.inputClass = ""; this.color = "#333333"; this.bgColor = "#EEEEEE"; this.buttonWidth = 60; this.buttonWords = "选择日期"; this.canEdits = true; this.hidesSelects = true; this.functionCode = ""; this.yearText="年"; this.nextYearText="下一年"; this.preYearText="上一年"; this.monthText="月"; this.nextMonthText="下一月"; this.preMonthText="上一月"; this.monday="一";// mon. this.tuesday="二";// tues. this.wednesday="三";// wed. this.thursday="四";// thurs. this.friday="五";// fri. this.saturday="六";// sat. this.sunday="日";// sun. ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// //定义display方法。 this.display = function () { var reDate = /^(19[7-9]\d|20[0-5]\d)\-(0?\d|1[0-2])\-([0-2]?\d|3[01])$/; if (reDate.test(this.inputValue)) { var dates = this.inputValue.split("-"); var year = parseInt(dates[0], 10); var month = parseInt(dates[1], 10); var mday = parseInt(dates[2], 10); } else { var today = new Date(); var year = today.getFullYear(); var month = Add0(today.getMonth()+1); var mday = Add0(today.getDate()); } if (this.inputValue == "today") inputValue = year + "-" + month + "-" + mday; else inputValue = this.inputValue; var lastDay = new Date(year, month, 0); lastDay = lastDay.getDate(); var firstDay = new Date(year, month-1, 1); firstDay = firstDay.getDay(); var btnBorder = "border-left:1px solid " + this.color + ";" + "border-right:1px solid " + this.color + ";" + "border-top:1px solid " + this.color + ";" + "border-bottom:1px solid " + this.color + ";"; var btnStyle = "padding-top:3px;cursor:default;width:" + this.buttonWidth + "px;text-align:center;height:18px;top:-9px;" + "font:normal 12px 宋体;position:absolute;z-index:99;background-color:" + this.bgColor + ";" + "line-height:12px;" + btnBorder + "color:" + this.color + ";"; var boardStyle = "position:absolute;width:1px;height:1px;background:" + this.bgColor + ";top:8px;border:1px solid "+ this.color + ";display:none;padding:3px;"; var buttonEvent = " onmouseover=\"this.childNodes[0].style.borderBottom='0px';" + "this.childNodes[1].style.display='';this.style.zIndex=100;" + (this.hidesSelects ? "var slts=document.getElementsByTagName('SELECT');" + "for(var i=0;i"; output += " "; output += "
"; output += "
" + this.buttonWords + "
"; output += "
"; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; output += " "; var day = 1; for (var row=0; row<6; row++) { output += ""; for (var col=0; col<7; col++) { if (row == 0 && col < firstDay) output += ""; else if (day <= lastDay) { output += ""; day++; } else output += ""; } output += ""; } output += "
<<<"; output += " " + year + ""+this.yearText+"" + month + ""+this.monthText+""; output += " >>>
"+this.sunday+""+this.monday+""+this.tuesday+""+this.wednesday+""+this.thursday+""+this.friday+""+this.saturday+"
 " + day + "
"; output += "
"; output += "
"; output += " "; output += ""; document.write(output); } ///////////////////////////////////////////////////////////////////////// }