关键词:js,周调用,js获取周时间段,js获取下一个月周时间段,和每个周的时间段,保存为.html运行试试看.
这个是对js获取一个月有几周(时间段)的补充
<html>
<head>
<title>显示日期调用来自>
</head>
<script language="javascript">
<!--for asp .cn
function lu_datechange()
{
var lu_shouyear=document.getElementById("lu_shouyear");
var lu_shoumonth=document.getElementById("lu_shoumonth");
var lu_showweek=document.getElementById("lu_showweek");
var lu_showweek_begin=document.getElementById("lu_showweek_begin");
var lu_showweek_end=document.getElementById("lu_showweek_end");
var end_temp="";
var begin_temp2="";
var weeknum="";
var tempnum=0;
if((lu_shouyear.value!="")&&(lu_shoumonth.value!=""))
{
var temp_btime=new Date(lu_shouyear.value+"/"+lu_shoumonth.value+"/1");//获取选择年月的1号
var tempnum=temp_btime.getDay();//网站制作学习网fora s p .c n获取选择日期的星期几0表示日
if(tempnum==0){tempnum=7}
var temp_now=new Date();
if (!lu_checkdate(temp_now,temp_btime))
{
var begin_temp=(new Date(temp_btime.setDate(temp_btime.getDate()-(tempnum-1))));//获取了开始日期------就是日期开始的
lu_showweek_begin.value=(begin_temp.getFullYear())+"-"+(begin_temp.getMonth()+1)+"-"+(begin_temp.getDate());
begin_temp2=begin_temp;
var tempobj=document.getElementById("setweeknum");//
for (i=1;i<7;i++)
{
begin_temp2=(new Date(begin_temp2.setDate(begin_temp2.getDate()+7)));
if(parseInt(begin_temp2.getMonth()+1)!=parseInt(lu_shoumonth.value))
{end_temp=(new Date(begin_temp2.setDate(begin_temp2.getDate()-8)));//w获w取w .最f后o一r个a周s日p.cn
break;}
else
{weeknum++;tempobj.options[weeknum]= new Option(weeknum,weeknum);}
}
lu_showweek.value=weeknum;
lu_showweek_end.value=(end_temp.getFullYear())+"-"+(end_temp.getMonth()+1)+"-"+(end_temp.getDate());
}
else
{
alert("超过当前日期了!");
}
}
}
function lu_checkdate(temp_now,temp_btime)
{
if(temp_now<temp_btime)
{return true;}
else
{return false;}
}
function lu_changeweeknum(n)
{
var lu_showweek_begin=document.getElementById("lu_showweek_begin");
if ((n!="")&&(lu_showweek_begin.value!=""))
{
//alert(n+"xxx"+(lu_showweek_begin.value.getDate()));
var templu_showweek_begin=(lu_showweek_begin.value.replace(/-/g,"/"));
templu_showweek_begin=new Date(templu_showweek_begin);
begin_temp=(new Date(templu_showweek_begin.setDate(templu_showweek_begin.getDate()+(n-1)*7)));
end_temp=(new Date(templu_showweek_begin.setDate(templu_showweek_begin.getDate()+7*n)));
lu_showweek_begin.value=(begin_temp.getFullYear())+"-"+(begin_temp.getMonth()+1)+"-"+(begin_temp.getDate());
lu_showweek_end.value=(end_temp.getFullYear())+"-"+(end_temp.getMonth()+1)+"-"+(end_temp.getDate());
}
}
-->
</script>
<body>
<select id="lu_shouyear" style="width:60px;" onChange="lu_datechange();">
<option value="" selected="selected">年份</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
</select>
<select id="lu_shoumonth" style="width:50px;" onChange="lu_datechange();">
<option value="" selected="selected">月份</option>
<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>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>本月共有
<input type="text" id="lu_showweek" size="2" readonly="readonly">
<select id="setweeknum" onChange="lu_changeweeknum(this.value);">
<option value="" selected>周</option>
</select>个星期
开始时间是:<input type="text" id="lu_showweek_begin" size="10" maxlength="10"/>
结束时间是:<input type="text" id="lu_showweek_end" size="10" maxlength="10" />
</body>
</html>
中国足彩网信息请查看IT技术专栏