




免费预览已结束,剩余4页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JSP点击输入框弹出日期选择 New Document !-/* * 创建日历层的核心函数 * param Object theTextObject input元素对象 * param Number sStartYear 指定起始的年份 * param Number sEndYear 指定截止的年份 * param Number sStartMonth 指定起始的月份 * param Number sEndMonth 指定截止的月份*/function DefineMonthView(theTextObject,sStartYear,sEndYear,sStartMonth,sEndMonth) this.startYear=2000;/默认起始年份 this.endYear=2013; /默认截止年份 this.startMonth=1; /默认起始月份 this.endMonth=12; /默认截止月份 this.Source=theTextObject; /元素对象 this.yearSelectName=yearSelect; /年份select元素名 this.monthSelectName=monthSelect; /月份select元素名 this.HeaderStyle = height:32px; background-color:#E3F0FF; /tr元素样式; this.Width = 200; /定义月份视图的主体宽度 this.Height = 40; /定义月份视图的主体高度 this.MonthGridStyle = border-width:1px; border-style:solid; border-color:#000000; /table元素样式 this.SubmitButStyle = font-size:12px; font-family:宋体;background-color:#F2F8FF; /button元素样式this.ResetButStyle= font-size:12px; font-family:宋体;background-color:#F2F8FF; this.divID=nego_orange /div元素id this.SubmitButName=submit; /button元素名称this.ResetButName=reset1; this.date=new Date(); /获得当前日期对象 this.selectedYear=this.date.getYear(); /得到当前年份 this.selectedMonth=this.date.getMonth()+1; /得到当年月份 this.YearListStyle = font-size:12px; font-family:宋体; /年份select元素样式 this.MonthListStyle = font-size:12px; font-family:宋体; /月份select元素样式 /如果指定起始年份参数不为空将其设为起始年份 if(sStartYear!=null) this.startYear=sStartYear; /如果指定截止年份参数不为空将其设为截止年份 if(sEndYear!=null) this.endYear=sEndYear; /如果指定起始月份参数不为空将其设为起始月份 if(sStartMonth!=null) this.startMonth=sStartMonth; /如果指定截止月份参数不为空将其设为截止月份 if(sEndMonth!=null) this.endMonth=sEndMonth; /从input元素中取值如果是合法年份且在起始年份截止年份, /起始月份截止月份以内则默认选中为input元素中的值, /否则默认选中值为当前年月this.setSelectValue= function() var arrayDate=null; var tempYear=null; var tempMonth=null; var regexText=/d1,4-d1,2$/; var tempValue=this.Source.value; if(regexText.test(tempValue) arrayDate=tempValue.split(-); tempYear=parseInt(arrayDate0,10); tempMonth=parseInt(arrayDate1,10); if(tempYear=this.startYear)&(tempYear=this.startMonth)&(tempMonth=this.endMonth) this.selectedYear=tempYear; this.selectedMonth=tempMonth else if(tempYear=this.startYear)&(tempYear=this.startMonth)&(tempMonth=this.endMonth) this.selectedYear=tempYear; this.selectedMonth=tempMonth else if(tempYear=this.startYear)&(tempYear=this.startMonth)&(tempMonth=this.startYear)&(tempYear=this.startMonth)&(tempMonth=this.endMonth) this.selectedYear=tempYear; this.selectedMonth=tempMonth /* * 得到年份option字符串的方法 * param Number startYear 默认起始年份 * param Number endYear 默认截止年份 * param Number selectedYear 默认选中年份 */ this.getYearOptions= function(startYear,endYear,selectedYear) var yearOptionStr=; for(var i=0;i=(endYear-startYear);i+) if(selectedYear=(startYear+i) yearOptionStr+=+(startYear+i)+年; else yearOptionStr+=+(startYear+i)+年; return yearOptionStr; /* * 得到月份option字符串的方法 * param Number startYear 默认起始月份 * param Number endYear 默认截止月份 * param Number selectedYear 默认选中月份 */ this.getMonthOptions= function(startMonth,endMonth,selectedMonth) var monthOptionStr=; for(var i=0;i=(endMonth-startMonth);i+) var disMonth=startMonth+i; if(disMonth10) if(selectedMonth=(disMonth) monthOptionStr+=+disMonth+月; else monthOptionStr+=+disMonth+月; else if(selectedMonth=(disMonth) monthOptionStr+=+disMonth+月; else monthOptionStr+=+disMonth+月; return monthOptionStr; /* * 得到div元素左侧坐标的函数 * param Object theObject input元素对象 */ this.GetoffsetLeft= function(theObject) var absLeft = 0; var thePosition=; var tmpObject = theObject; while (tmpObject != null) thePosition = tmpObject.position; tmpObject.position = static; absLeft += tmpObject.offsetLeft; tmpObject.position = thePosition; tmpObject = tmpObject.offsetParent; return absLeft; /*得到div元素顶部坐标的函数 * param Object theObject input元素对象 */ this.GetoffsetTop= function(theObject) var absTop = 0; var thePosition = ; var tmpObject = theObject; while (tmpObject != null) thePosition = tmpObject.position; tmpObject.position = static; absTop += tmpObject.offsetTop; tmpObject.position = thePosition; tmpObject = tmpObject.offsetParent; return absTop; /* * 删除div的函数 */ this.DeleteMonthGrid= function() var theDivObject = document.all.item(this.divID); if (theDivObject = null) return; var tmpObject = document.activeElement; while (tmpObject != null) if (tmpObject = this.Source) return; if (tmpObject.id = this.yearSelectName) return; if (tmpObject.id = this.monthSelectName) return; if (tmpObject.id = this.SubmitButName) var theDivObject = document.all.item(this.divID); yearSelectObj=document.allthis.yearSelectName; monthSelectObj=document.allthis.monthSelectName; this.Source.value=yearSelectObj.optionsyearSelectObj.selectedIndex.value+ -+monthSelectObj.optionsmonthSelectObj.selectedIndex.value; theDivObject.outerHTML=; this.Source = null;return;if (tmpObject.id = this.ResetButName)this.Source.value=;theDivObject.outerHTML=; this.Source = null;return; tmpObject = tmpObject.parentElement; if (tmpObject = null) theDivObject.outerHTML=; this.Source = null; /* * 初始化div元素的函数 */ this.InitialMonthView= function() var theDivHTML=; theDivHTML=; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ;theDivHTML += ;theDivHTML += ; theDivHTML += this.getYearOptions(this.startYear,this.endYear,this.selectedYear); theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += this.getMonthOptions(this.startMonth,this.endMonth,this.selectedMonth); theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; theDivHTML += ; document.body.insertAdjacentHTML(beforeEnd, theDivHTML); theDivObject = document.all.item(this.divID); theDivObject.style.position = absolute; theDivObject.style.posLeft = this.GetoffsetLeft(this.Source); theDivObject.style.posTop = this.GetoffsetTop(this.Source) + this.Source.offsetHeight; /* * 创建日历层的函数 * param Object theTextObject input元素对象 * param Number sStartYear 指定起始的年份 * param Number sEndYear 指定截止的年份 * param Num
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 机床考试题目及答案
- 激光光谱分析技术基本原理试题及答案
- 网络时代的护士资格证复习试题及答案
- 网络规划设计师考试的评估与反馈及试题及答案
- 系统架构设计师关键技术框架试题及答案
- 医学人文期末试题及答案
- 激光治疗技术的临床研究试题及答案
- 共青团理论试题及答案
- 系统架构考试深度思考试题及答案
- 药品安全使用相关法规试题及答案
- 2025江苏无锡江阴公用事业集团限公司招聘1人易考易错模拟试题(共500题)试卷后附参考答案
- 湖北省咸宁市2025年高考数学试题全真模拟卷
- 食品生产设施安全设计试题及答案
- iata第 66版危险货物规则(dgr 66th)
- 《中国古代寓言》导读(课件)2023-2024学年统编版语文三年级下册
- 个人简历电子版表格下载
- GB/T 16823.3-2010紧固件扭矩-夹紧力试验
- 夕阳箫鼓-钢琴谱(共11页)
- 地面沉降监测技术要求
- 基本建设项目建设成本管理规定解读
- 金色的鱼钩课本剧
评论
0/150
提交评论