01.
<SCRIPT LANGUAGE=
"JavaScript"
>
02.
<!-- Begin
03.
var
now =
new
Date();
04.
var
month_array =
new
Array(
"มกราคม"
,
"กุมภาพันธ์"
,
"มีนาคม"
,
"เมษายน"
,
"พฤษภาคม"
,
"มิถุนายน"
,
"กรกฎาคม"
,
"สิงหาคม"
,
"กันยายน"
,
"ตุลาคม"
,
"พฤศจิกายน"
,
"ธันวาคม"
);
05.
document.write(
"<form name=date_list><table bgcolor=silver><tr><td>"
);
06.
document.write(
"<select name=month onchange=change_month(this.options.selectedIndex)>"
);
07.
for
(i=0;i<month_array.length;i++)
08.
{
09.
if
(now.getMonth() != i)
10.
{document.write (
"<option value="
+i+
">"
+month_array[i]);}
11.
else
12.
{document.write (
"<option value="
+i+
" selected>"
+month_array[i]);}
13.
14.
}
15.
document.write(
"</select>"
);
16.
document.write(
"</td><td>"
);
17.
document.write (
"<select name=year onchange=change_year(this.options[this.options.selectedIndex])>"
);
18.
for
(i=1950;i<3000;i++)
19.
{
20.
if
(now.getYear() != i)
21.
{document.write(
"<option value="
+i+
">"
+i);}
22.
else
23.
{document.write(
"<option value="
+i+
" selected>"
+i);}
24.
}
25.
document.write(
"</select></td></tr><tr><td colspan=2><center>"
);
26.
27.
document.write(
"<table bgcolor=white border=0 cellspacing = 0 cellpading = 0 width=100%><tr bgcolor=gray align=center>"
);
28.
document.write(
"<td><font color=black>จ</font></td><td><font color=black>อ</td><td><font color=black>พ</td><td><font color=black>พฤ</td><td><font color=black>ศ</td><td ><font color=black>ส</td><td ><font color=black>อ</td>"
);
29.
document.write(
"</tr><tr>"
);
30.
for
(j=0;j<6;j++)
31.
{
32.
for
(i=0;i<7;i++)
33.
{
34.
document.write(
"<td align=center id=d"
+i+
"r"
+j+
"></td>"
)
35.
}
36.
document.write(
"</tr>"
);
37.
}
38.
39.
document.write(
"</table>"
);
40.
41.
document.write(
"</center></from></td></tr></table>"
);
42.
43.
var
show_date =
new
Date();
44.
45.
function
set_cal(show_date)
46.
{
47.
begin_day =
new
Date (show_date.getYear(),show_date.getMonth(),1);
48.
begin_day_date = begin_day.getDay();
49.
end_day =
new
Date (show_date.getYear(),show_date.getMonth()+1,1);
50.
count_day = (end_day - begin_day)/1000/60/60/24;
51.
input_table(begin_day_date,count_day);
52.
}
53.
set_cal(show_date);
54.
55.
function
input_table(begin,count)
56.
{
57.
init();
58.
j=0;
59.
if
(begin!=0){i=begin-1;}
else
{i=6}
60.
for
(c=1;c<count+1;c++)
61.
{
62.
colum_name = eval(
"d"
+i+
"r"
+j);
63.
if
((now.getDate() == c)&&(show_date.getMonth() == now.getMonth())&&(show_date.getYear() == now.getYear())) {colum_name.style.backgroundColor =
"blue"
;colum_name.style.color =
"white"
;};
64.
colum_name.innerText = c;
65.
i++;
66.
if
(i==7){i=0;j++;}
67.
}
68.
}
69.
70.
function
init()
71.
{
72.
for
(j=0;j<6;j++)
73.
{
74.
for
(i=0;i<7;i++)
75.
{
76.
colum_name = eval(
"d"
+i+
"r"
+j);
77.
colum_name.innerText =
"-"
;
78.
colum_name.style.backgroundColor =
""
;
79.
colum_name.style.color =
""
;
80.
}
81.
}
82.
}
83.
84.
function
change_month(sel_month)
85.
{
86.
show_date =
new
Date(show_date.getYear(),sel_month,1);
87.
set_cal(show_date);
88.
}
89.
90.
function
change_year(sel_year)
91.
{
92.
sel_year = sel_year.value;
93.
show_date =
new
Date(sel_year,show_date.getMonth(),1);
94.
set_cal(show_date);
95.
}
96.
97.
</script>