js级联显示年月日周代码

<script>
function getWeekdayName()
{
var week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

var y,m,d;
y=document.frmDate.selYear.value;
m=document.frmDate.selMonth.value;
d=document.frmDate.selDate.value;

var dd=new Date( y + "/" + m + "/" +d );
w=dd.getDay();

var op=new Option
op.value=week[w];
op.text=week[w];
document.frmDate.selWeek.options[0]=op;
}


function changeLastDay()
{
var i;
var len=document.frmDate.selDate.options.length;
for( i=0; i<len; i++)
{
document.frmDate.selDate.options.remove (0)
}
//----------------------claar
var days=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);

var y=document.frmDate.selYear.value;
if(y % 400==0 || y % 100 !=0 && y%4 == 0 )
days[2]=29;

var m=document.frmDate.selMonth.value;

var op;
for( i=1; i<=days[m]; i++ )
{
op=new Option;
op.value=i;
op.text=i;
document.frmDate.selDate.options[i-1]=op;
}
}

</script>
<!-- ------------------------------------------------->
<form name=frmDate>
<select name=selYear onChange="changeLastDay();getWeekdayName();">
<script>
var y
var t=new Date();
for(y=1970;y<=t.getFullYear();y++)
{
if(y==1980)
document.write("<option value="+y+ " selected>"+y+"</option>");
else
document.write("<option value="+y+">"+y+"</option>");
}
</script>
</select>年

<select name=selMonth onChange="changeLastDay();getWeekdayName();">
<script>
var m
for(m=1;m<=12;m++)
{
document.write("<option value="+m+">"+m+"</option>")
}
</script>
</select>月

<select name=selDate οnchange="getWeekdayName();">
<script>
var d
for(d=1;d<=31;d++)
{
document.write("<option value="+d+">"+d+"</option>")
}
</script>
</select>日
<select name=selWeek >
<script>
getWeekdayName();
</script>
</script>
</form> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值