温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:科信客户关系管理系统源码
当前文件路径:KeXinCrm/images/birthday.js

1//日历 2
var date_start,date_end,g_object 3
var today = new Date(); 4
var separator="-"; 5
var inover=false; 6
7
//mode :时间变换的类型0-年 1-月 2-直接选择月 8
function change_date(temp,mode) 9
{ 10
var t_month,t_year 11
if (mode){ 12
if(mode==1) 13
t_month=parseInt(cele_date_month.value,10)+parseInt(temp,10); 14
else 15
t_month=parseInt(temp) 16
if (t_month<cele_date_month.options(0).text) { 17
cele_date_month.value=cele_date_month.options(cele_date_month.length-1).text; 18
change_date(parseInt(cele_date_year.value,10)-1,0); 19
} 20
else{ 21
if (t_month>cele_date_month.options(cele_date_month.length-1).text){ 22
cele_date_month.value=cele_date_month.options(0).text; 23
change_date(parseInt(cele_date_year.value,10)+1,0); 24
} 25
else 26
{cele_date_month.value=t_month; 27
set_cele_date(cele_date_year.value,cele_date_month.value); 28
} 29
} 30
} 31
else{ 32
t_year=parseInt(temp,10); 33
34
if (t_year<cele_date_year.options(0).text) { 35
cele_date_year.value=cele_date_year.options(0).text; 36
set_cele_date(cele_date_year.value,1); 37
} 38
else{ 39
if (parseInt(t_year,10)>parseInt(cele_date_year.options(cele_date_year.length-1).text,10)){ 40
cele_date_year.value=cele_date_year.options(cele_date_year.length-1).text; 41
set_cele_date(cele_date_year.value,12); 42
} 43
else 44
{cele_date_year.value=t_year; 45
set_cele_date(cele_date_year.value,cele_date_month.value); 46
} 47
} 48
} 49
50
window.cele_date.focus(); 51
52
} 53
54
//初始化日历 55
function init(d_start,d_end) 56
{ 57
var temp_str; 58
var i=0 59
var j=0 60
date_start=new Date(1980,7,1) 61
date_end=new Date(2004,8,1) 62
document.writeln("<div name=\"cele_date\" id=\"cele_date\" style=\"display:none\" style=\"LEFT: 69px; POSITION: absolute; TOP: 159px;Z-INDEX:99\" onClick=\"event.cancelBubble=true;\" onBlur=\"hilayer()\" onMouseout=\"lostlayerfocus()\">-</div>"); 63
window.cele_date.innerHTML=""; 64
temp_str="<table border=\"1\" bgcolor=\"#DDDDDD\" bordercolor=\"white\"><tr><td colspan=7 onmouseover=\"overcolor(this)\">"; 65
temp_str+="<input type=\"Button\" value=\"<<\" onclick=\"change_date(-1,1)\" onmouseover=\"getlayerfocus()\" style=\"color: #000099; background-color: #BFBFBF; cursor: hand\">-"; 66
67
temp_str+="" 68
temp_str+="<select name=\"cele_date_year\" id=\"cele_date_year\" language=\"javascript\" onchange=\"change_date(this.value,0)\" onmouseover=\"getlayerfocus()\" onblur=\"getlayerfocus()\" style=\"font-size: 9pt; border: 1px #666666 outset; background-color: #F4F8FB\">" 69
70
for (i=1900;i<=2020;i++) 71
{ 72
temp_str+="<OPTION value=\""+i.toString()+"\">"+i.toString()+"</OPTION>"; 73
} 74
temp_str+="</select>-"; 75
temp_str+="" 76
temp_str+="<select name=\"cele_date_month\" id=\"cele_date_month\" language=\"javascript\" onchange=\"change_date(this.value,2)\" onmouseover=\"getlayerfocus()\" onblur=\"getlayerfocus()\" style=\"font-size: 9pt; border: 1px #666666 outset; background-color: #F4F8FB\">" 77
78
for (i=1;i<=12;i++) 79
{ 80
temp_str+="<OPTION value=\""+i.toString()+"\">"+i.toString()+"</OPTION>"; 81
} 82
temp_str+="</select>-"; 83
temp_str+="" 84
temp_str+="<input type=\"Button\" value=\">>\" onclick=\"change_date(1,1)\" onmouseover=\"getlayerfocus()\" style=\"color: #000099; background-color: #BFBFBF; cursor: hand\">"; 85
86
temp_str+="</td></tr><tr><td onmouseover=\"overcolor(this)\">" 87
temp_str+="<font color=red>7</font></td><td>";temp_str+="1</td><td>"; temp_str+="2</td><td>"; temp_str+="3</td><td>" 88
temp_str+="4</td><td>";temp_str+="5</td><td>"; temp_str+="6</td></tr>"; 89
for (i=1 ;i<=6 ;i++) 90
{ 91
temp_str+="<tr>"; 92
for(j=1;j<=7;j++){ 93
temp_str+="<td name=\"c"+i+"_"+j+"\"id=\"c"+i+"_"+j+"\" style=\"CURSOR: hand\" style=\"COLOR:#000000\" language=\"javascript\" onmouseover=\"overcolor(this)\" onmouseout=\"outcolor(this)\" onclick=\"td_click(this)\">?</td>" 94
} 95
temp_str+="</tr>" 96
} 97
temp_str+="</td></tr></table>"; 98
window.cele_date.innerHTML=temp_str; 99
} 100
function set_cele_date(year,month) 101
{ 102
var i,j,p,k 103
var nd=new Date(year,month-1,1); 104
event.cancelBubble=true; 105
cele_date_year.value=year; 106
cele_date_month.value=month; 107
k=nd.getDay()-1 108
var temp; 109
for (i=1;i<=6;i++) 110
for(j=1;j<=7;j++) 111
{ 112
eval("c"+i+"_"+j+".innerHTML=\"\""); 113
eval("c"+i+"_"+j+".bgColor=\"#DDDDDD\""); 114
eval("c"+i+"_"+j+".style.cursor=\"hand\""); 115
} 116
while(month-1==nd.getMonth()) 117
{ j=(nd.getDay() +1); 118
p=parseInt((nd.getDate()+k) / 7)+1; 119
eval("c"+p+"_"+j+".innerHTML="+"\""+nd.getDate()+"\""); 120
if ((nd.getDate()==today.getDate())&&(cele_date_month.value==today.getMonth()+1)&&(cele_date_year.value==today.getYear())){ 121
eval("c"+p+"_"+j+".bgColor=\"#EFFB64\""); 122
} 123
if (nd>date_end || nd<date_start) 124
{ 125
eval("c"+p+"_"+j+".bgColor=\"#FF9999\""); 126
eval("c"+p+"_"+j+".style.cursor=\"text\""); 127
} 128
nd=new Date(nd.valueOf() + 86400000) 129
} 130
} 131
132
//s_object:点击的对象;d_start-d_end有效的时间区段;需要存放值的控件; 133
function show_cele_date(eP,d_start,d_end,t_object) 134
{ 135
window.cele_date.style.display=""; 136
window.cele_date.style.zIndex=99 137
var s,cur_d 138
var eT = eP.offsetTop; 139
var eH = eP.offsetHeight+eT; 140
var dH = window.cele_date.style.pixelHeight; 141
var sT = document.body.scrollTop; 142
var sL = document.body.scrollLeft; 143
event.cancelBubble=true; 144
window.cele_date.style.posLeft = event.clientX-event.offsetX+sL-5; 145
window.cele_date.style.posTop = event.clientY-event.offsetY+eH+sT-5; 146
if (window.cele_date.style.posLeft+window.cele_date.clientWidth>document.body.clientWidth) window.cele_date.style.posLeft+=eP.offsetWidth-window.cele_date.clientWidth; 147
if (d_start!=""){ 148
if (d_start=="today"){ 149
date_start=new Date(today.getYear(),today.getMonth(),today.getDate()); 150
}else{ 151
s=d_start.split(separator); 152
date_start=new Date(s[0],s[1]-1,s[2]); 153
} 154
}else{ 155
date_start=new Date(1900,1,1); 156
} 157
158
if (d_end!=""){ 159
s=d_end.split(separator); 160
date_end=new Date(s[0],s[1]-1,s[2]); 161
}else{ 162
date_end=new Date(3000,1,1); 163
} 164
165
g_object=t_object 166
167
cur_d=new Date() 168
set_cele_date(cur_d.getYear(),cur_d.getMonth()+1); 169
window.cele_date.style.display="block"; 170
171
window.cele_date.focus(); 172
173
} 174
function td_click(t_object) 175
{ 176
var t_d 177
if (parseInt(t_object.innerHTML,10)>=1 && parseInt(t_object.innerHTML,10)<=31 ) 178
{ t_d=new Date(cele_date_year.value,cele_date_month.value-1,t_object.innerHTML) 179
if (t_d<=date_end && t_d>=date_start) 180
{ 181
var year = cele_date_year.value; 182
var month = cele_date_month.value; 183
var day = t_object.innerHTML; 184
if (parseInt(month)<10) month = "0" + month; 185
if (parseInt(day)<10) day = "0" + day; 186
187
g_object.value=year+separator+month+separator+day; 188
window.cele_date.style.display="none";}; 189
} 190
191
} 192
function h_cele_date() 193
{ 194
window.cele_date.style.display="none"; 195
} 196
197
function overcolor(obj) 198
{ 199
if (obj.style.cursor=="hand") obj.style.color = "#FFFFFF"; 200
201
inover=true; 202
window.cele_date.focus(); 203
204
} 205
206
function outcolor(obj) 207
{ 208
obj.style.color = "#000000"; 209
inover=false; 210
211
} 212
213
function getNow(o){ 214
var Stamp=new Date(); 215
var year = Stamp.getYear(); 216
var month = Stamp.getMonth()+1; 217
var day = Stamp.getDate(); 218
if(month<10){ 219
month="0"+month; 220
} 221
if(day<10){ 222
day="0"+day; 223
} 224
o.value=year+separator+month+separator+day; 225
} 226
227
function hilayer() 228
{ 229
if (inover==false) 230
{ 231
var lay=document.all.cele_date; 232
lay.style.display="none"; 233
} 234
} 235
function getlayerfocus() 236
{ 237
inover=true; 238
} 239
function lostlayerfocus() 240
{ 241
inover=false; 242
} 243
init(); 244
//日历结束 245





}
}