-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.html
More file actions
132 lines (106 loc) · 2.82 KB
/
Copy pathtable.html
File metadata and controls
132 lines (106 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<head style="text-align: center;">
<title>日历</title>
</head>
<body>
<table id="calendertable">
<thead >
<tr>
<td colspan="7" class="head1" width="50%">日历</td>
</tr>
<tr>
<td colspan="7" class="head2">
<t id="year">1992</t> 年 <t id="month"></t> 月<t id="day"></t>日
</td>
</tr>
<tr >
<th>周日</th>
<th>周一</th>
<th>周二</th>
<th>周三</th>
<th>周四</th>
<th>周五</th>
<th>周六</th>
</tr>
</thead>
<tbody >
<tr >
<td id = "box" colspan="7" >
</td>
</tr>
</tbody>
</table>
<!-- <div id="log"></div> -->
</body>
<style>
table {
width:100%;
border:1px solid black;
text-align: center;
border-collapse: collapse;
/* border-spacing: 0ch; */
/* margin: 01; */
}
th,td{
border: 1px solid black;
padding: 0;
}
.head1{
text-align: center;
background-color: antiquewhite;
text-align: justify;
text-justify: distribute-all-lines;
text-align-last: justify;
width: 50%;
}
.head2{
text-align: center;
}
</style>
<script>
function $(id) {
return document.getElementById(id);
}
function create(tagName) {
return document.createElement(tagName);
}
function caltable(daytime, ctable) {
// ctable.style="table";
// ctable.style.width="100%";
// ctable.border="1";
const myDay= daytime.getDate();
daytime.setDate(0);
const lastday=daytime.getDate();
daytime.setDate(1);
const firstday=daytime;
var startwrite=false;
var writeday=1;
for(var j = 0; j < 5;j++) {
var oTr=create('tr');
for(var i=0; i< 7;i++) {
var oTd=create('td');
if(j == 0 && i==firstday.getDay()) {
startwrite=true;
}
if (startwrite && writeday<=lastday) {
oTd.innerHTML=writeday.toString();
if(writeday==myDay) {
oTd.style.backgroundColor="antiquewhite";
}
writeday++;
}
oTr.appendChild(oTd);
}
ctable.appendChild(oTr);
}
ctable.style.border=0;
$('box').appendChild(ctable);
}
const today=new Date();
$('year').innerHTML = today.getFullYear();
$("month").innerHTML = today.getMonth() + 1 ;
$("day").innerHTML = today.getDate();
// $("log").innerHTML = today.getDay();
var x=caltable(new Date(),$("calendertable"));
</script>
</html>