Javascrpt日期控件例子.docVIP

  • 7
  • 0
  • 约2.48万字
  • 约 16页
  • 2016-10-18 发布于贵州
  • 举报
Javascrpt日期控件例子

示例1. 效果图如下 代码 script Stotype.Format = function(){ var tmpStr = this; var iLen = arguments.length; for(var i=0;iiLen;i++){ tmpStr = tmpStr.replace(new RegExp(\\{ + i + \\}, g), arguments[i]); } return tmpStr; } Calendar = { //region Property today : new Date(), year : 2005, month : 8, date : 21, curPosX : 0, curPosY : 0, curCapture : null, curDay : null, //endregion //region Method display : function(o, e, d){ with(Calendar){ o = typeof(o) == object ? o : document.getElementById(o); if(window.event){ curPosX = document.body.scrollLeft + event.x; curPosY = document.body.scrollTop + event.y; } else{ curPosX = e.pageX; curPosY = e.pageY; } if(o.value == d) o.value = d; with(document.getElementById(Calendar__)){ if(o != curCapture) { curCapture = o; if(style.display == block){ style.left = curPosX + px; style.top = curPosY + px; } else load(); } else{ if (style.display == block) style.display = none; else load(); } } } }, load : function(){ with(Calendar){ curDay = loadDate(curCapture.value); with(curDay){ year = getFullYear(); month = getMonth() + 1; date = getDate(); } init(); } }, init : function(){ with(Calendar){ with(new Date(year, month-1, date)){ year = getFullYear(); month = getMonth() + 1; date = getDate(); setDate(1); var first = getDay(); setMonth(getMonth()+1, 0) paint(first, getDate()); } } }, paint : function(first, last){ var calendar = document.getElementById(Calendar__); var grid = document.getElementById(dataGrid__); var i, l; l = Math.ceil((first + last)/7); if(!document.all){ calendar.style.height = (41 + 19 * Math.ceil((first + last)/7)) + px; } grid.innerHTML = new Array(l*7 + 1).join(lia/a/li); with(Calendar){ var strDate = {0}-{1}.Format(year, month); var isTodayMonth = ((year == today.getFullYear()) (month == today.getMo

文档评论(0)

1亿VIP精品文档

相关文档