成语| 古诗大全| 教学资源| 作文| 扒知识| 扒知识繁体

当前位置:首页 > 趣味生活

javascript日期选择器

Q1:javascript 日期联动选择器 [其中的一些代码值得学习]

DateSelectorbody {margin: 0px;padding: 0px;font-size: 12px;}#year, #month, #date{width: 60px;margin-right: 3px;}var $ = function(id) { return string == typeof id ? document.getElementById(id) : id; };var Extend = function(destination, source) {for(var pro in source) {destination[pro] = source[pro];}return destination;}var addEvent = function(obj, type, fn) {if(obj.addEventListener) {obj.addEventListener(type, fn, false);return true;}else if(obj.attachEvent) {obj[e+type+fn] = fn;obj[type+fn] = function(){obj[e+type+fn](window.event);}obj.attachEvent(on+type, obj[type+fn]);return true;}return false;}/*!*DateSelector** Copyright (c) 2009 GoodNess2010* Date: 2009-12-15 (星期二)*/function DateSelector(idYear, idMonth, idDate, options) {var D = new Date();this.year = $(idYear);this.month = $(idMonth);this.date = $(idDate);this.nowYear = D.getFullYear();this.nowMonth = D.getMonth() + 1;this.nowDate = D.getDate();Extend(this, this.setOptions(options));};DateSelector.prototype = {setOptions: function(options){// 默认项this.options = {floorYear: 5,// 距当前年份前5年ceilYear: 7,// 距当前年份后7年onStart: function(){}, // 前置事件onEnd: function(){}// 结束事件};return Extend(this.options, options{});},createOption: function(container, start, end, sign){sign = signstart;var _num = parseInt(end-start+1, 10); container.options.length = _num;for(var i = 0; i = _num ? _num-1 : sign-start);},getDate: function(y, m){return new Date(y, m, 0).getDate();},getSelText: function(sel) {return sel.options[sel.selectedIndex].text;},changeDate: function(bindO){var _this = this;addEvent(bindO, change, function(){var y = _this.getSelText(_this.year), m = _this.getSelText(_this.month), d = _this.getSelText(_this.date);_this.createOption(_this.date, 1, _this.getDate(y, m), d);_this.onEnd();});},bindEvents: function(){var _this = this;this.changeDate(this.year); this.changeDate(this.month);addEvent(this.date, change, function(){ _this.onEnd(); });},init: function(){var _startYear = parseInt(this.nowYear - this.floorYear, 10);var _endYear = parseInt(this.nowYear + this.ceilYear, 10);var _endDate = this.getDate(this.nowYear, this.nowMonth, 0);this.createOption(this.year, _startYear, _endYear, this.nowYear);this.createOption(this.month, 1, 12, this.nowMonth);this.createOption(this.date, 1, _endDate, this.nowDate);this.bindEvents();this.onStart();}};var dateSelector = new DateSelector(year, month, date, {floorYear: 1});dateSelector.onStart = dateSelector.onEnd = function(){$(info).innerHTML = this.getSelText(this.year) + 年 +(0 + this.getSelText(this.month)).slice(-2) + 月 +(0 + this.getSelText(this.date)).slice(-2) + 日;}dateSelector.init();[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
[参数说明]
复制代码 代码如下:
var dateSelector = new DateSelector(年下拉ID, 月下拉ID, 日下拉ID, {floorYear: 向前几年, ceilYear: 向后几年});
dateSelector.onStart = dateSelector.onEnd = function(){ // 自定义开始结束事件
$(info).innerHTML = this.getSelText(this.year) + 年 +
(0 + this.getSelText(this.month)).slice(-2) + 月 +
(0 + this.getSelText(this.date)).slice(-2) + 日;
}
dateSelector.init(); // 初始化开始 [说明文字]
这里生成option的方法选择了中规中矩的options[i].text = options[i].value = https://www.swansea86.com/bazhishi/aldyjtapi/i;
期间用过一个这个方法:
container.options[container.options.length] = new Option(i, i, false, (i == sign ? true : false))
这个new Option有4个参数可用(text, value, defaultSelected, selected); 最后一个参数可以设置选中.
但一直没有查到官方资料. 在IE6中也遇到了BUG.大家有用过的请指正.
BUG演示
这个在IE7,IE8,FF3等都没问题.但在IE6就会选中的是前一个.现在还未知原因. (经过确认好像是IE Tester的问题.那么下面这个方案也是个简洁的生成option方案) 测试代码:
复制代码 代码如下:

<script type="text/javascript">

</script>

Q2:用javascript做一个这样的日期选择器

累死我了,总算写好了。在chrome上开发,没测试其他浏览器
自觉注释写得很清楚了,你自己看吧。
但愿度娘不要吞我的回答



<meta charset="utf-8">
日期选择器--何凯作品
成语| 古诗大全| 教学资源| 作文| 扒知识| 扒知识繁体
<style type="text/css">
div,input,select,input,p {
margin: 0;
padding: 0;
}
.date-selector {
position: relative;
margin: 20px;
}
.date-select-box {
position: absolute;
top: 22px;
left: 40px;
padding: 8px 5px;
display: none;
background-color: #fff;
z-index: 9999;
}
.date-selected-box, .date-select-box, .date-select-box select {
border: 1px solid #676dff;
}
</style>
<body>


爸爸的生日:







妈妈的生日:







我的生日:







<script type="text/javascript">
//工具集
var Tools = {
//a是否在数组b中
inArray: function(a, b) {
for(var i=0; i if(a==b[i]) return i;
}
return -1;
},
//获取某年某月的天数
getNumberOfDays: function(year,month){
if(this.inArray(month, [1,3,5,7,8,10,12])>0) return 31;
else if(this.inArray(month, [4,6,9,11])>0) return 30;
else if(year%4 == 0 && year%100 != 0year%400 == 0) return 29;
else return 28;
}
};
//日期选择器类,传入日期div的id名,div的结构参考上面的html,同一个页面上可以有多个ID不同的日期选择器
var DateSelector = function(dateSelector) {
if(typeof dateSelector !== string) return false;
//获取DOM
this.dateSelector = document.getElementById(dateSelector);
this.dateSelectedBox = this.dateSelector.querySelector(.date-selected-box);
this.dateSelectBox = this.dateSelector.querySelector(.date-select-box);
this.dateSelectElement = {
year : this.dateSelector.querySelector(.date-select-year),
month : this.dateSelector.querySelector(.date-select-month),
day : this.dateSelector.querySelector(.date-select-day),
sure : this.dateSelector.querySelector(.date-select-sure)
};
//定义option模板
this.optionTpl = {
normal: ,
selected:
};
this.dateObj = new Date();
//获取日期
this.today = {
year: this.dateObj.getFullYear(),
month: this.dateObj.getMonth()+1,
day: this.dateObj.getDate()
};
//填充选项
this.fillSelectFields();
//绑定事件
this.bind();
};
//定义方法
DateSelector.prototype = {
//显示/隐藏选项框
showSelectBox: function(){
this.dateSelectBox.style.display = block;
},
hideSelectBox: function(){
this.dateSelectBox.style.display = none;
},
//设置文本框的值,传入带有year,month,day属性的对象
fillSelectedBox: function(o){
this.dateSelectedBox.value = https://www.swansea86.com/bazhishi/aldyjtapi/o.year+年+o.month+月+o.day+日;
},
//用从start到end的数字选项option填充某个select元素element,selected数为默认选中,option Template见上方定义
fillSelectField: function(element, start, end, selected){
var tmp = [];
for(var i = start; i <= end; i++) {
var tpl = i===selected?this.optionTpl.selected:this.optionTpl.normal;
tmp.push(tpl.replace({$v}, i));
}
element.innerHTML = tmp.join(\n);
},
//填充日月年的选项
fillSelectFields: function(){
this.fillSelectField(this.dateSelectElement.year, this.today.year-99, this.today.year, this.today.year);
this.fillSelectField(this.dateSelectElement.month, 1, 12, this.today.month);
this.fillSelectField(this.dateSelectElement.day, 1, Tools.getNumberOfDays(this.today.year, this.today.month), this.today.day);
},
//绑定事件
bind: function(){
//保存指向类的指针
var _this = this;
_this.dateSelectedBox.onclick = function(){
_this.showSelectBox();
};
_this.dateSelectElement.sure.onclick = function(){
_this.fillSelectedBox({
year: _this.dateSelectElement.year.value,
month: _this.dateSelectElement.month.value,
day: _this.dateSelectElement.day.value
});
_this.hideSelectBox();
};
//当 年 或 月 的值改变时调整 日 的可选值
_this.dateSelectElement.year.onchange = _this.dateSelectElement.month.onchange = function(){
//为了方便计算,把dom中的alue转为整型
var y = parseInt(_this.dateSelectElement.year.value, 10),
m = parseInt(_this.dateSelectElement.month.value, 10);
_this.fillSelectField(_this.dateSelectElement.day, 1, Tools.getNumberOfDays(y, m), 1);
};
} }; //实例化类
new DateSelector(date-selector-1);
new DateSelector(date-selector-2);
new DateSelector(date-selector-3);</script>

Q3:javascript英文日期(有时间)选择器

varlanguageCode=en;//Possiblevalues:en,ge,no,nl,es,pt-br,fr
//en=english,ge=german,no=norwegian,nl=dutch,es=spanish,pt-br=portuguese,fr=french,da=danish,hu=hungarian(UseUTF-8doctypeforhungarian)
varcalendar_display_time=true;
//Formatofcurrentdayatthebottomofthecalendar
//[todayString]=thevalueoftodayString
//[dayString]=dayofweek(examle:mon,tue,wed...)
//[UCFdayString]=dayofweek(examle:Mon,Tue,Wed...)(Firstletterinuppercase)
//[day]=Dayofmonth,1..31
//[monthString]=Nameofcurrentmonth
//[year]=Currentyear
vartodayStringFormat=[todayString][UCFdayString].[day].[monthString][year];
varpathToImages=images/;//RelativetoyourHTMLfile
varspeedOfSelectBoxSliding=200;//Millisecondsbetweenchangingyearandhourwhenholdingmouseover"-"and"+"-lowervalue=https://www.swansea86.com/bazhishi/aldyjtapi/faster
varintervalSelectBox_minutes=5;//Minuteselectbox-intervalbetweeneachoption(5=default)
varcalendar_offsetTop=0;//Offset-calendarplacement-Youprobablyhavetomodifythisvalueifyourenotusingastrictdoctype
varcalendar_offsetLeft=0;//Offset-calendarplacement-Youprobablyhavetomodifythisvalueifyourenotusingastrictdoctype
varcalendarDiv=false;
varMSIE=false;
varOpera=false;
if(navigator.userAgent.indexOf(MSIE)>=0&&navigator.userAgent.indexOf(Opera)<0)MSIE=true;
if(navigator.userAgent.indexOf(Opera)>=0)Opera=true; switch(languageCode){
case"en":/*English*/
varmonthArray=[January,February,March,April,May,June,July,August,September,October,November,December];
varmonthArrayShort=[Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec];
vardayArray=[Mon,Tue,Wed,Thu,Fri,Sat,Sun];
varweekString=Week;
vartodayString=;
break;
case"ge":/*German*/
varmonthArray=[Januar,Februar,M鋜z,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember];
varmonthArrayShort=[Jan,Feb,Mar,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez];
vardayArray=[Mon,Die,Mit,Don,Fre,Sam,Son];
varweekString=Woche;
vartodayString=Heute;
break;
case"no":/*Norwegian*/
varmonthArray=[Januar,Februar,Mars,April,Mai,Juni,Juli,August,September,Oktober,November,Desember];
varmonthArrayShort=[Jan,Feb,Mar,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Des];
vardayArray=[Man,Tir,Ons,Tor,Fre,Lør,Søn];
varweekString=Uke;
vartodayString=Dagenidager;
break;
case"nl":/*Dutch*/
varmonthArray=[Januari,Februari,Maart,April,Mei,Juni,Juli,Augustus,September,Oktober,November,December];
varmonthArrayShort=[Jan,Feb,Mar,Apr,Mei,Jun,Jul,Aug,Sep,Okt,Nov,Dec];
vardayArray=[Ma,Di,Wo,Do,Vr,Za,Zo];
varweekString=Week;
vartodayString=Vandaag;
break;
case"es":/*Spanish*/
varmonthArray=[Enero,Febrero,Marzo,April,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre];
varmonthArrayShort=[Ene,Feb,Mar,Abr,May,Jun,Jul,Ago,Sep,Oct,Nov,Dic];
vardayArray=[Lun,Mar,Mie,Jue,Vie,Sab,Dom];
varweekString=Semana;
vartodayString=Hoyes;
break;
case"pt-br":/*Brazilianportuguese(pt-br)*/
varmonthArray=[Janeiro,Fevereiro,Março,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro];
varmonthArrayShort=[Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez];
vardayArray=[Seg,Ter,Qua,Qui,Sex,Sáb,Dom];
varweekString=Sem.;
vartodayString=Hojeé;
break;
case"fr":/*French*/
varmonthArray=[Janvier,F関rier,Mars,Avril,Mai,Juin,Juillet,Ao鹴,Septembre,Octobre,Novembre,D閏embre];
varmonthArrayShort=[Jan,Fev,Mar,Avr,Mai,Jun,Jul,Aou,Sep,Oct,Nov,Dec];
vardayArray=[Lun,Mar,Mer,Jeu,Ven,Sam,Dim];
varweekString=Sem;
vartodayString="Aujourdhui";
break;
case"da":/*Danish*/
varmonthArray=[januar,februar,marts,april,maj,juni,juli,august,september,oktober,november,december];
varmonthArrayShort=[jan,feb,mar,apr,maj,jun,jul,aug,sep,okt,nov,dec];
vardayArray=[man,tirs,ons,tors,fre,lør,søn];
varweekString=Uge;
vartodayString=Idagerden;
break;
case"hu":/*Hungarian-RemembertouseUTF-8encoding,i.e.the<meta>tag*/
varmonthArray=[Janu谩r,Febru谩r,M谩rcius,?prilis,M谩jus,J煤nius,J煤lius,Augusztus,Szeptember,Okt贸ber,November,December];
varmonthArrayShort=[Jan,Feb,M谩rc,?pr,M谩j,J煤n,J煤l,Aug,Szep,Okt,Nov,Dec];
vardayArray=[H茅,Ke,Sze,Cs,P茅,Szo,Vas];
varweekString=H茅t;
vartodayString=Mainap;
break;
case"it":/*Italian*/
varmonthArray=[Gennaio,Febbraio,Marzo,Aprile,Maggio,Giugno,Luglio,Agosto,Settembre,Ottobre,Novembre,Dicembre];
varmonthArrayShort=[Gen,Feb,Mar,Apr,Mag,Giu,Lugl,Ago,Set,Ott,Nov,Dic];
vardayArray=[Lun,;Mar,Mer,Gio,Ven,Sab,Dom];
varweekString=Settimana;
vartodayString=Oggièil;
break;
case"sv":/*Swedish*/
varmonthArray=[Januari,Februari,Mars,April,Maj,Juni,Juli,Augusti,September,Oktober,November,December];
varmonthArrayShort=[Jan,Feb,Mar,Apr,Maj,Jun,Jul,Aug,Sep,Okt,Nov,Dec];
vardayArray=[Mån,Tis,Ons,Tor,Fre,Lör,Sön];
varweekString=Vecka;
vartodayString=Idagärdetden;
break;
}
vardaysInMonthArray=[31,28,31,30,31,30,31,31,30,31,30,31];
varcurrentMonth;
varcurrentYear;
varcurrentHour;
varcurrentMinute;
varcalendarContentDiv;
varreturnDateTo;
varreturnFormat;
varactiveSelectBoxMonth;
varactiveSelectBoxYear;
varactiveSelectBoxHour;
varactiveSelectBoxMinute;
variframeObj=false;
////fixforEIframeproblemontimedropdowns09/30/2006
variframeObj2=false;
functionEIS_FIX_EI1(where2fixit)
{
if(!iframeObj2)return;
iframeObj2.style.display=block;
iframeObj2.style.height=document.getElementById(where2fixit).offsetHeight+1;
iframeObj2.style.width=document.getElementById(where2fixit).offsetWidth;
iframeObj2.style.left=getleftPos(document.getElementById(where2fixit))+1-calendar_offsetLeft;
iframeObj2.style.top=getTopPos(document.getElementById(where2fixit))-document.getElementById(where2fixit).offsetHeight-calendar_offsetTop;
}
functionEIS_Hide_Frame()
{if(iframeObj2)iframeObj2.style.display=none;}
////fixforEIframeproblemontimedropdowns09/30/2006
varreturnDateToYear;
varreturnDateToMonth;
varreturnDateToDay;
varreturnDateToHour;
varreturnDateToMinute;
varinputYear;
varinputMonth;
varinputDay;
varinputHour;
varinputMinute;
varcalendarDisplayTime=false;
varselectBoxHighlightColor=#D60808;//Highlightcolorofselectboxes
varselectBoxRolloverBgColor=#E2EBED;//Backgroundcolorondropdownlists(rollover)
varselectBoxMovementInProgress=false;
varactiveSelectBox=false;
functioncancelCalendarEvent()
{
returnfalse;
}
functionisLeapYear(inputYear)
{
if(inputYear%400==0(inputYear%4==0&&inputYear%100!=0))returntrue;
returnfalse;
}
varactiveSelectBoxMonth=false;
varactiveSelectBoxDirection=false;
functionhighlightMonthYear()
{
if(activeSelectBoxMonth)activeSelectBoxMonth.className=;
activeSelectBox=this;
if(this.className==monthYearActive){
this.className=;
}else{
this.className=monthYearActive;
activeSelectBoxMonth=this;
}
if(this.innerHTML.indexOf(-)>=0this.innerHTML.indexOf(+)>=0){
if(this.className==monthYearActive)
selectBoxMovementInProgress=true;
else
selectBoxMovementInProgress=false;
if(this.innerHTML.indexOf(-)>=0)activeSelectBoxDirection=-1;elseactiveSelectBoxDirection=1;
}elseselectBoxMovementInProgress=false;
}
functionshowMonthDropDown()
{
if(document.getElementById(monthDropDown).style.display==block){
document.getElementById(monthDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
}else{
document.getElementById(monthDropDown).style.display=block;
document.getElementById(yearDropDown).style.display=none;
document.getElementById(hourDropDown).style.display=none;
document.getElementById(minuteDropDown).style.display=none;
if(MSIE)
{EIS_FIX_EI1(monthDropDown)}
////fixforEIframeproblemontimedropdowns09/30/2006
}
}
functionshowYearDropDown()
{
if(document.getElementById(yearDropDown).style.display==block){
document.getElementById(yearDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
}else{
document.getElementById(yearDropDown).style.display=block;
document.getElementById(monthDropDown).style.display=none;
document.getElementById(hourDropDown).style.display=none;
document.getElementById(minuteDropDown).style.display=none;
if(MSIE)
{EIS_FIX_EI1(yearDropDown)}
////fixforEIframeproblemontimedropdowns09/30/2006
}
}
functionshowHourDropDown()
{
if(document.getElementById(hourDropDown).style.display==block){
document.getElementById(hourDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
}else{
document.getElementById(hourDropDown).style.display=block;
document.getElementById(monthDropDown).style.display=none;
document.getElementById(yearDropDown).style.display=none;
document.getElementById(minuteDropDown).style.display=none;
if(MSIE)
{EIS_FIX_EI1(hourDropDown)}
////fixforEIframeproblemontimedropdowns09/30/2006
}
}
functionshowMinuteDropDown()
{
if(document.getElementById(minuteDropDown).style.display==block){
document.getElementById(minuteDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
}else{
document.getElementById(minuteDropDown).style.display=block;
document.getElementById(monthDropDown).style.display=none;
document.getElementById(yearDropDown).style.display=none;
document.getElementById(hourDropDown).style.display=none;
if(MSIE)
{EIS_FIX_EI1(minuteDropDown)}
////fixforEIframeproblemontimedropdowns09/30/2006
}
}
functionselectMonth()
{
document.getElementById(calendar_month_txt).innerHTML=this.innerHTML
currentMonth=this.id.replace(/[^\d]/g,);
document.getElementById(monthDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
for(varno=0;nodocument.getElementById(monthDiv_+no).style.color=;
}
this.style.color=selectBoxHighlightColor;
activeSelectBoxMonth=this;
writeCalendarContent();
}
functionselectHour()
{
document.getElementById(calendar_hour_txt).innerHTML=this.innerHTML
currentHour=this.innerHTML.replace(/[^\d]/g,);
document.getElementById(hourDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
if(activeSelectBoxHour){
activeSelectBoxHour.style.color=;
}
activeSelectBoxHour=this;
this.style.color=selectBoxHighlightColor;
}
functionselectMinute()
{
document.getElementById(calendar_minute_txt).innerHTML=this.innerHTML
currentMinute=this.innerHTML.replace(/[^\d]/g,);
document.getElementById(minuteDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
if(activeSelectBoxMinute){
activeSelectBoxMinute.style.color=;
}
activeSelectBoxMinute=this;
this.style.color=selectBoxHighlightColor;
} functionselectYear()
{
document.getElementById(calendar_year_txt).innerHTML=this.innerHTML
currentYear=this.innerHTML.replace(/[^\d]/g,);
document.getElementById(yearDropDown).style.display=none;
////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();
if(activeSelectBoxYear){
activeSelectBoxYear.style.color=;
}
activeSelectBoxYear=this;
this.style.color=selectBoxHighlightColor;
writeCalendarContent();
}
functionswitchMonth()
{
if(this.src.indexOf(left)>=0){
currentMonth=currentMonth-1;;
if(currentMonth<0){
currentMonth=11;
currentYear=currentYear-1;
}
}else{
currentMonth=currentMonth+1;;
if(currentMonth>11){
currentMonth=0;
currentYear=currentYear/1+1;
}
}
writeCalendarContent();
}
functioncreateMonthDiv(){
vardiv=document.createElement(DIV);
div.className=monthYearPicker;
div.id=monthPicker;
for(varno=0;novarsubDiv=document.createElement(DIV);
subDiv.innerHTML=monthArray[no];
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=highlightMonthYear;
subDiv.onclick=selectMonth;
subDiv.id=monthDiv_+no;
subDiv.style.width=56px;
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
if(currentMonth&¤tMonth==no){
subDiv.style.color=selectBoxHighlightColor;
activeSelectBoxMonth=subDiv;
}
}
returndiv;
}
functionchangeSelectBoxYear(e,inputObj)
{
if(!inputObj)inputObj=this;
varyearItems=inputObj.parentNode.getElementsByTagName(DIV);
if(inputObj.innerHTML.indexOf(-)>=0){
varstartYear=yearItems[1].innerHTML/1-1;
if(activeSelectBoxYear){
activeSelectBoxYear.style.color=;
}
}else{
varstartYear=yearItems[1].innerHTML/1+1;
if(activeSelectBoxYear){
activeSelectBoxYear.style.color=;
}
}
for(varno=1;noyearItems[no].innerHTML=startYear+no-1;
yearItems[no].id=yearDiv+(startYear/1+no/1-1);
}
if(activeSelectBoxYear){
activeSelectBoxYear.style.color=;
if(document.getElementById(yearDiv+currentYear)){
activeSelectBoxYear=document.getElementById(yearDiv+currentYear);
activeSelectBoxYear.style.color=selectBoxHighlightColor;;
}
}
}
functionchangeSelectBoxHour(e,inputObj)
{
if(!inputObj)inputObj=this;
varhourItems=inputObj.parentNode.getElementsByTagName(DIV);
if(inputObj.innerHTML.indexOf(-)>=0){
varstartHour=hourItems[1].innerHTML/1-1;
if(startHour<0)startHour=0;
if(activeSelectBoxHour){
activeSelectBoxHour.style.color=;
}
}else{
varstartHour=hourItems[1].innerHTML/1+1;
if(startHour>14)startHour=14;
if(activeSelectBoxHour){
activeSelectBoxHour.style.color=;
}
}
varprefix=;
for(varno=1;noif((startHour/1+no/1)<11)prefix=0;elseprefix=;
hourItems[no].innerHTML=prefix+(startHour+no-1);
hourItems[no].id=hourDiv+(startHour/1+no/1-1);
}
if(activeSelectBoxHour){
activeSelectBoxHour.style.color=;
if(document.getElementById(hourDiv+currentHour)){
activeSelectBoxHour=document.getElementById(hourDiv+currentHour);
activeSelectBoxHour.style.color=selectBoxHighlightColor;;
}
}
}
functionupdateYearDiv()
{
vardiv=document.getElementById(yearDropDown);
varyearItems=div.getElementsByTagName(DIV);
for(varno=1;noyearItems[no].innerHTML=currentYear/1-6+no;
if(currentYear==(currentYear/1-6+no)){
yearItems[no].style.color=selectBoxHighlightColor;
activeSelectBoxYear=yearItems[no];
}else{
yearItems[no].style.color=;
}
}
}
functionupdateMonthDiv()
{
for(no=0;no<12;no++){
document.getElementById(monthDiv_+no).style.color=;
}
document.getElementById(monthDiv_+currentMonth).style.color=selectBoxHighlightColor;
activeSelectBoxMonth=document.getElementById(monthDiv_+currentMonth);
} functionupdateHourDiv()
{
vardiv=document.getElementById(hourDropDown);
varhourItems=div.getElementsByTagName(DIV);
varaddHours=0;
if((currentHour/1-6+1)<0){
addHours=(currentHour/1-6+1)*-1;
}
for(varno=1;novarprefix=;
if((currentHour/1-6+no+addHours)<10)prefix=0;
hourItems[no].innerHTML=prefix+(currentHour/1-6+no+addHours);
if(currentHour==(currentHour/1-6+no)){
hourItems[no].style.color=selectBoxHighlightColor;
activeSelectBoxHour=hourItems[no];
}else{
hourItems[no].style.color=;
}
}
}
functionupdateMinuteDiv()
{
for(no=0;no<60;no+=intervalSelectBox_minutes){
varprefix=;
if(no<10)prefix=0;
document.getElementById(minuteDiv_+prefix+no).style.color=;
}
if(document.getElementById(minuteDiv_+currentMinute)){
document.getElementById(minuteDiv_+currentMinute).style.color=selectBoxHighlightColor;
activeSelectBoxMinute=document.getElementById(minuteDiv_+currentMinute);
}
}
functioncreateYearDiv()
{
if(!document.getElementById(yearDropDown)){
vardiv=document.createElement(DIV);
div.className=monthYearPicker;
}else{
vardiv=document.getElementById(yearDropDown);
varsubDivs=div.getElementsByTagName(DIV);
for(varno=0;nosubDivs[no].parentNode.removeChild(subDivs[no]);
}
}
vard=newDate();
if(currentYear){
d.setFullYear(currentYear);
}
varstartYear=d.getFullYear()/1-5;
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=-;
subDiv.onclick=changeSelectBoxYear;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
for(varno=startYear;no<(startYear+10);no++){
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=no;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=highlightMonthYear;
subDiv.onclick=selectYear;
subDiv.id=yearDiv+no;
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
if(currentYear&¤tYear==no){
subDiv.style.color=selectBoxHighlightColor;
activeSelectBoxYear=subDiv;
}
}
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=+;
subDiv.onclick=changeSelectBoxYear;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
returndiv;
}
/*Thisfunctioncreatesthehourdivatthebottombar*/
functionslideCalendarSelectBox()
{
if(selectBoxMovementInProgress){
if(activeSelectBox.parentNode.id==hourDropDown){
changeSelectBoxHour(false,activeSelectBox);
}
if(activeSelectBox.parentNode.id==yearDropDown){
changeSelectBoxYear(false,activeSelectBox);
}
}
setTimeout(slideCalendarSelectBox(),speedOfSelectBoxSliding);
}
functioncreateHourDiv()
{
if(!document.getElementById(hourDropDown)){
vardiv=document.createElement(DIV);
div.className=monthYearPicker;
}else{
vardiv=document.getElementById(hourDropDown);
varsubDivs=div.getElementsByTagName(DIV);
for(varno=0;nosubDivs[no].parentNode.removeChild(subDivs[no]);
}
}
if(!currentHour)currentHour=0;
varstartHour=currentHour/1;
if(startHour>14)startHour=14;
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=-;
subDiv.onclick=changeSelectBoxHour;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
for(varno=startHour;novarprefix=;
if(no/1<10)prefix=0;
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=prefix+no;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=highlightMonthYear;
subDiv.onclick=selectHour;
subDiv.id=hourDiv+no;
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
if(currentYear&¤tYear==no){
subDiv.style.color=selectBoxHighlightColor;
activeSelectBoxYear=subDiv;
}
}
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=+;
subDiv.onclick=changeSelectBoxHour;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
returndiv;
}
/*Thisfunctioncreatestheminutedivatthebottombar*/
functioncreateMinuteDiv()
{
if(!document.getElementById(minuteDropDown)){
vardiv=document.createElement(DIV);
div.className=monthYearPicker;
}else{
vardiv=document.getElementById(minuteDropDown);
varsubDivs=div.getElementsByTagName(DIV);
for(varno=0;nosubDivs[no].parentNode.removeChild(subDivs[no]);
}
}
varstartMinute=0;
varprefix=;
for(varno=startMinute;no<60;no+=intervalSelectBox_minutes){
if(no<10)prefix=0;elseprefix=;
varsubDiv=document.createElement(DIV);
subDiv.innerHTML=prefix+no;
subDiv.onmouseover=highlightMonthYear;
subDiv.onmouseout=highlightMonthYear;
subDiv.onclick=selectMinute;
subDiv.id=minuteDiv_+prefix+no;
subDiv.onselectstart=cancelCalendarEvent;
div.appendChild(subDiv);
if(currentYear&¤tYear==no){
subDiv.style.color=selectBoxHighlightColor;
activeSelectBoxYear=subDiv;
}
}
returndiv;
}
functionhighlightSelect()
{
if(this.className==selectBoxTime){
this.className=selectBoxTimeOver;
this.getElementsByTagName(IMG)[0].src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down_time_over.gif;
}elseif(this.className==selectBoxTimeOver){
this.className=selectBoxTime;
this.getElementsByTagName(IMG)[0].src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down_time.gif;
}
if(this.className==selectBox){
this.className=selectBoxOver;
this.getElementsByTagName(IMG)[0].src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down_over.gif;
}elseif(this.className==selectBoxOver){
this.className=selectBox;
this.getElementsByTagName(IMG)[0].src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down.gif;
}
}
functionhighlightArrow()
{
if(this.src.indexOf(over)>=0){
if(this.src.indexOf(left)>=0)this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+left.gif;
if(this.src.indexOf(right)>=0)this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+right.gif;
}else{
if(this.src.indexOf(left)>=0)this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+left_over.gif;
if(this.src.indexOf(right)>=0)this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+right_over.gif;
}
}
functionhighlightClose()
{
if(this.src.indexOf(over)>=0){
this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+close.gif;
}else{
this.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+close_over.gif;
}
}
functioncloseCalendar(){
document.getElementById(yearDropDown).style.display=none;
document.getElementById(monthDropDown).style.display=none;
document.getElementById(hourDropDown).style.display=none;
document.getElementById(minuteDropDown).style.display=none;
calendarDiv.style.display=none;
if(iframeObj){
iframeObj.style.display=none;
////////fixforEIframeproblemontimedropdowns09/30/2006
EIS_Hide_Frame();}
if(activeSelectBoxMonth)activeSelectBoxMonth.className=;
if(activeSelectBoxYear)activeSelectBoxYear.className=; }
functionwriteTopBar()
{
vartopBar=document.createElement(DIV);
topBar.className=topBar;
topBar.id=topBar;
calendarDiv.appendChild(topBar);
//Leftarrow
varleftDiv=document.createElement(DIV);
leftDiv.style.marginRight=1px;
varimg=document.createElement(IMG);
img.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+left.gif;
img.onmouseover=highlightArrow;
img.onclick=switchMonth;
img.onmouseout=highlightArrow;
leftDiv.appendChild(img);
topBar.appendChild(leftDiv);
if(Opera)leftDiv.style.width=16px;
//Rightarrow
varrightDiv=document.createElement(DIV);
rightDiv.style.marginRight=1px;
varimg=document.createElement(IMG);
img.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+right.gif;
img.onclick=switchMonth;
img.onmouseover=highlightArrow;
img.onmouseout=highlightArrow;
rightDiv.appendChild(img);
if(Opera)rightDiv.style.width=16px;
topBar.appendChild(rightDiv);
//Monthselector
varmonthDiv=document.createElement(DIV);
monthDiv.id=monthSelect;
monthDiv.onmouseover=highlightSelect;
monthDiv.onmouseout=highlightSelect;
monthDiv.onclick=showMonthDropDown;
varspan=document.createElement(SPAN);
span.innerHTML=monthArray[currentMonth];
span.id=calendar_month_txt;
monthDiv.appendChild(span);
varimg=document.createElement(IMG);
img.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down.gif;
img.style.position=absolute;
img.style.right=0px;
monthDiv.appendChild(img);
monthDiv.className=selectBox;
if(Opera){
img.style.cssText=float:right;position:relative;
img.style.position=relative;
img.style.styleFloat=right;
}
topBar.appendChild(monthDiv);
varmonthPicker=createMonthDiv();
monthPicker.style.left=37px;
monthPicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+px;
monthPicker.style.width=60px;
monthPicker.id=monthDropDown;
calendarDiv.appendChild(monthPicker);
//Yearselector
varyearDiv=document.createElement(DIV);
yearDiv.onmouseover=highlightSelect;
yearDiv.onmouseout=highlightSelect;
yearDiv.onclick=showYearDropDown;
varspan=document.createElement(SPAN);
span.innerHTML=currentYear;
span.id=calendar_year_txt;
yearDiv.appendChild(span);
topBar.appendChild(yearDiv);
varimg=document.createElement(IMG);
img.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+down.gif;
yearDiv.appendChild(img);
yearDiv.className=selectBox;
if(Opera){
yearDiv.style.width=50px;
img.style.cssText=float:right;
img.style.position=relative;
img.style.styleFloat=right;
}
varyearPicker=createYearDiv();
yearPicker.style.left=113px;
yearPicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+px;
yearPicker.style.width=35px;
yearPicker.id=yearDropDown;
calendarDiv.appendChild(yearPicker);
varimg=document.createElement(IMG);
img.src=https://www.swansea86.com/bazhishi/aldyjtapi/pathToImages+close.gif;
img.style.styleFloat=right;
img.onmouseover=highlightClose;
img.onmouseout=highlightClose;
img.onclick=closeCalendar;
topBar.appendChild(img);
if(!document.all){
img.style.position=absolute;
img.style.right=2px;
}
}
functionwriteCalendarContent()
{
varcalendarContentDivExists=true;
if(!calendarContentDiv){
calendarContentDiv=document.createElement(DIV);
calendarDiv.appendChild(calendarContentDiv);
calendarContentDivExists=false;
}
currentMonth=currentMonth/1;
vard=newDate();
d.setFullYear(currentYear);
d.setDate(1);
d.setMonth(currentMonth);
vardayStartOfMonth=d.getDay();
if(dayStartOfMonth==0)dayStartOfMonth=7;
dayStartOfMonth--;
document.getElementById(calendar_year_txt).innerHTML=currentYear;
document.getElementById(calendar_month_txt).innerHTML=monthArray[currentMonth];
document.getElementById(calendar_hour_txt).innerHTML=currentHour;
document.getElementById(calendar_minute_txt).innerHTML=currentMinut

猜你喜欢

更多