发新话题
打印

源码学习:一个简单的日历控件(8)

源码学习:一个简单的日历控件(8)


//************* 插入日期单元格 **************/6 ]" M8 u* Y/ w2 A" Q
this.insertBodyCell=function(theRow,j,day,targetObject){
1 d1 O5 C7 I- w3 \* {$ ~ var theCell=theRow.insertCell(j);
% Q% ^6 l" [: e. a3 @, F: e if(j==0) var theBgColor="#FF9999";* A; q% e  L/ O
else var theBgColor="#FFFFFF";
  u- x5 N1 B" Z! _3 b# n if(day==calendar.currentDate[2]) var theBgColor="#CCCCCC";  c" `1 n0 i; [3 \
if(day==calendar.today[2]) var theBgColor="#99FFCC";
$ Q1 `) V% ]2 n- S3 M: A% h7 r+ } theCell.bgColor=theBgColor;
  \0 U1 @! ^, ?: {! O/ R. P theCell.innerText=day;; ?' m: @0 G& l) a8 W
theCell.align="center";
; Y/ A0 Y1 L6 n: r0 C: T8 B theCell.width=35;) c0 D8 Y1 X4 q/ {7 j# q
theCell.style.cssText="border:1 solid #CCCCCC;cursor:hand;";0 H0 u% ]$ I3 s- ]" v; T, \* V
theCell.onmouseover=function(){ 0 C( J& m) F6 d
theCell.bgColor="#FFFFCC"; 6 ^, p4 w7 w" u; Y( [
theCell.style.cssText="border:1 outset;cursor:hand;";
2 P8 p9 N8 U6 N& |! t3 s+ M9 Q }7 v9 H" D; f# \9 W* @: F
theCell.onmouseout=function(){ % u2 g+ N$ i& \& g
theCell.bgColor=theBgColor; 7 c3 j9 J! t) |1 D4 m4 B3 x) T5 p6 V5 L) j
theCell.style.cssText="border:1 solid #CCCCCC;cursor:hand;";7 f0 c6 N3 y4 h7 ?( z
}
. y# i  }" a$ Z8 ~% h theCell.onmousedown=function(){ ( V: o1 E! u- |8 |+ f) b
theCell.bgColor="#FFFFCC"; , P" A4 g* O; D) P1 r& {
theCell.style.cssText="border:1 inset;cursor:hand;";. f' A4 B, C1 P8 I
}
  S/ Z9 @7 L) U; ? theCell.onclick=function(){$ g* q( u  }. l9 E5 o$ i( ?
if(calendar.currentDate[1].length2) calendar.currentDate[1]="0" calendar.currentDate[1];
' a2 h$ b, {9 U- }% u, q if(day.toString().length2) day="0" day;
) ]& @% Z5 q5 \3 o) h2 H calendar.sltDate=calendar.currentDate[0] "-" calendar.currentDate[1] "-" day;
- X* l* P7 [2 f9 h2 I$ R/ l calendar.target.value=calendar.sltDate;
# G  z$ ^: G7 Q- u3 K$ t- T calendar.hide();( Q3 g+ f+ p3 N! D
}; O$ y: X8 w+ j6 V5 _3 n+ D" A
}
9 r4 H% a7 e# }9 j: o /************** 取得月份的第一天为星期几 *********************/
& b0 ^! `* Z7 p, `8 W# X) i0 p( h this.getFirstDay=function(theYear, theMonth){; i$ e& \  b9 p2 c8 C
var firstDate = new Date(theYear,theMonth-1,1);
6 G& J* ]) j! _ return firstDate.getDay();
& F$ n2 m- d& g7 u }1 w; K1 D' Y. M1 W$ v
/************** 取得月份共有几天 *********************/



点击图标进入精品网摘收藏 欢迎大家加入网络收藏夹

TOP

发新话题