js獲取周時(shí)間段
來源:易賢網(wǎng) 閱讀:3330 次 日期:2014-10-09 11:02:14
溫馨提示:易賢網(wǎng)小編為您整理了“js獲取周時(shí)間段”,方便廣大網(wǎng)友查閱!

關(guān)鍵詞:js,周調(diào)用,js獲取周時(shí)間段,js獲取下一個(gè)月周時(shí)間段,和每個(gè)周的時(shí)間段,保存為.html運(yùn)行試試看.

這個(gè)是對(duì)js獲取一個(gè)月有幾周(時(shí)間段)的補(bǔ)充

<html>

<head>

<title>顯示日期調(diào)用來自>

</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號(hào)

var tempnum=temp_btime.getDay();//網(wǎng)站制作學(xué)習(xí)網(wǎng)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個(gè)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("超過當(dāng)前日期了!");

}

}

}

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>個(gè)星期

開始時(shí)間是:<input type="text" id="lu_showweek_begin" size="10" maxlength="10"/>

結(jié)束時(shí)間是:<input type="text" id="lu_showweek_end" size="10" maxlength="10" />

</body>

</html>

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:js獲取周時(shí)間段
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)