<%
@LANGUAGE
=
"
JAVASCRIPT
"
CODEPAGE
=
"
932
"
%>
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " " http://www.w3.org/TR/html4/loose.dtd " >
< html >
< head >
< meta http - equiv = " Content-Type " content = " text/html; charset=shift_jis " >
< title > Untitled Document </ title >
</ head >
< script language = " javascript " type = " text/javascript " >
var i;
var j;
var dat;
var ye;
var m;
var d;
ye = 2005 ;
m = 1 ;
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " " http://www.w3.org/TR/html4/loose.dtd " >
< html >
< head >
< meta http - equiv = " Content-Type " content = " text/html; charset=shift_jis " >
< title > Untitled Document </ title >
</ head >
< script language = " javascript " type = " text/javascript " >
var i;
var j;
var dat;
var ye;
var m;
var d;
ye = 2005 ;
m = 1 ;
//设置date的初始值
dat = new Date(ye, m, 1 );
//当年份改变时,获取被选中的年份
function List1_onSelected(x)
... {
var list = document.F1.DropDownList1;
ye = list.options[x].value;
}
dat = new Date(ye, m, 1 );
//当年份改变时,获取被选中的年份
function List1_onSelected(x)
... {
var list = document.F1.DropDownList1;
ye = list.options[x].value;
}
//当月改变时,获取被选中的月
function List2_onSelected(x)
... {
var list = document.F1.DropDownList2;
m = list.options[x].value;
// window.confirm(parseInt(ye));
// window.alert( parseInt(m));
}
function List2_onSelected(x)
... {
var list = document.F1.DropDownList2;
m = list.options[x].value;
// window.confirm(parseInt(ye));
// window.alert( parseInt(m));
}
//按下按钮显示日历
function B1_onClick()
... {
var myTable;
myTable = document.getElementById("Table1");
function B1_onClick()
... {
var myTable;
myTable = document.getElementById("Table1");
//清空table
var allRows = myTable.getElementsByTagName("tr");
while(allRows.length > 1)
...{
myTable.deleteRow(1);
}
d = 0;
dat = new Date( parseInt(ye), parseInt(m) - 1, 1);
//确定每月的天数
switch(m.toString())
...{
case "2" :
if (ye % 4 == 0 && ye % 100 != 0 || ye % 400 == 0)
...{
d = 29;
}
else
...{
d = 28;
}
break;
case "1" :
case "3" :
case "5" :
case "7" :
case "8" :
case "10" :
case "12" :
d = 31;
break;
case "4" :
case "6" :
case "9" :
case "11" :
d = 30;
break;
}
var i = 0;
var dd = new Date(parseInt(ye), parseInt(m) - 1, 1);
var wee = dd.getDay();
var newRow = myTable.insertRow();
var newCell;
var k = 1;
var allRows = myTable.getElementsByTagName("tr");
while(allRows.length > 1)
...{
myTable.deleteRow(1);
}
d = 0;
dat = new Date( parseInt(ye), parseInt(m) - 1, 1);
//确定每月的天数
switch(m.toString())
...{
case "2" :
if (ye % 4 == 0 && ye % 100 != 0 || ye % 400 == 0)
...{
d = 29;
}
else
...{
d = 28;
}
break;
case "1" :
case "3" :
case "5" :
case "7" :
case "8" :
case "10" :
case "12" :
d = 31;
break;
case "4" :
case "6" :
case "9" :
case "11" :
d = 30;
break;
}
var i = 0;
var dd = new Date(parseInt(ye), parseInt(m) - 1, 1);
var wee = dd.getDay();
var newRow = myTable.insertRow();
var newCell;
var k = 1;
//如果第一天不是星期天,要空出来几个位子
if(k == 1 && parseInt(wee) != 0)
...{
for(var h = 0; h < wee; h ++ )
...{
newCell = newRow.insertCell();
newCell.innerText = " ";
}
}
if(k == 1 && parseInt(wee) != 0)
...{
for(var h = 0; h < wee; h ++ )
...{
newCell = newRow.insertCell();
newCell.innerText = " ";
}
}
//然后逐个插入天数
for(k = 1; k <= d; k ++ )
...{
var date = new Date(parseInt(ye), parseInt(m) - 1, k);
var w = date.getDay();
newCell = newRow.insertCell();
newCell.innerText = k.toString();
if(w == 6 && k != d)
...{
newRow = myTable.insertRow();
}
}
}
</ script >
< body >
< form method = " post " id = " form1 " name = " F1 " >
< div >
< select name = " DropDownList1 " id = " DropDownList1 " size = " 1 " onchange = " List1_onSelected(options.selectedIndex) " >
< option value = " 2005 " > 2005 </ option >
< option value = " 2006 " > 2006 </ option >
< option value = " 2007 " > 2007 </ option >
< option value = " 2008 " > 2008 </ option >
</ select >
< select name = " DropDownList2 " id = " DropDownList2 " size = " 1 " onchange = " List2_onSelected(options.selectedIndex) " >
< option value = " 1 " > 1 </ option >
< option value = " 2 " > 2 </ option >
< option value = " 3 " > 3 </ option >
< option value = " 4 " > 4 </ option >
< option value = " 5 " > 5 </ option >
</ select >< input type = " button " value = " B1 " name = " B1 " onclick = " B1_onClick() " >
< table id = " Table1 " border = " 1 " >
< tr >
< td > Sun </ td >
< td > Mon </ td >
< td > Tue </ td >
< td > Wen </ td >
< td > Thu </ td >
< td > Fri </ td >
< td > Sat </ td >
</ tr >
</ table >
</ div >
</ form >
</ body >
</ html >
for(k = 1; k <= d; k ++ )
...{
var date = new Date(parseInt(ye), parseInt(m) - 1, k);
var w = date.getDay();
newCell = newRow.insertCell();
newCell.innerText = k.toString();
if(w == 6 && k != d)
...{
newRow = myTable.insertRow();
}
}
}
</ script >
< body >
< form method = " post " id = " form1 " name = " F1 " >
< div >
< select name = " DropDownList1 " id = " DropDownList1 " size = " 1 " onchange = " List1_onSelected(options.selectedIndex) " >
< option value = " 2005 " > 2005 </ option >
< option value = " 2006 " > 2006 </ option >
< option value = " 2007 " > 2007 </ option >
< option value = " 2008 " > 2008 </ option >
</ select >
< select name = " DropDownList2 " id = " DropDownList2 " size = " 1 " onchange = " List2_onSelected(options.selectedIndex) " >
< option value = " 1 " > 1 </ option >
< option value = " 2 " > 2 </ option >
< option value = " 3 " > 3 </ option >
< option value = " 4 " > 4 </ option >
< option value = " 5 " > 5 </ option >
</ select >< input type = " button " value = " B1 " name = " B1 " onclick = " B1_onClick() " >
< table id = " Table1 " border = " 1 " >
< tr >
< td > Sun </ td >
< td > Mon </ td >
< td > Tue </ td >
< td > Wen </ td >
< td > Thu </ td >
< td > Fri </ td >
< td > Sat </ td >
</ tr >
</ table >
</ div >
</ form >
</ body >
</ html >