行業(yè)動(dòng)態(tài)
JS一周值表(分上下午)
發(fā)布日期:2011-04-06 閱讀次數(shù):3476 字體大?。?a href="javascript:;" onclick="ChangeFontSize('content',16)">大
<script type=text/javascript>
function jinrizhiban(){
//把需要排班的姓名按照排班順序?qū)懺谙旅嬉恍欣锩婢涂梢?
var pers=new Array('<font color=ff0000>上午值班:</font>徐峻&nbsp;&nbsp;張解忠','<font color=ff0000>下午值班:</font>吳志兵','<font color=ff0000>值班:</font>查敦傳&nbsp;徐峻&nbsp;吳志兵&nbsp;許剛','<font color=ff0000>下午值班:</font>張解忠&nbsp;許剛','<font color=ff0000>上午值班:</font>徐峻&nbsp;&nbsp;許剛','<font color=ff0000>下午值班:</font>吳志兵&nbsp;&nbsp;許剛','<font color=ff0000>上午值班:</font>徐峻&nbsp;&nbsp;許剛','<font color=ff0000>下午值班:</font>張解忠&nbsp;&nbsp;許剛','<font color=ff0000>上午值班:</font>吳志兵&nbsp;徐峻&nbsp;許剛','<font color=ff0000>下午值班:</font>徐峻&nbsp;&nbsp;許剛','<font color=ff0000>上午值班:</font>吳志兵&nbsp;&nbsp;許剛','<font color=ff0000>下午值班:</font>徐峻&nbsp;&nbsp;許剛','<font color=ff0000>上午值班:</font>吳志兵&nbsp;徐峻&nbsp;許剛','<font color=ff0000>下午值班:</font>許剛');
//調(diào)整下面的調(diào)整因子,能控制啟用程序的那天由誰(shuí)值班,以后都能自動(dòng)更新顯示
var ctrl_param=6;
var now=new Date();
var days=parseInt(now.getTime()/12/3600/1000);
return pers[(days+ctrl_param) % pers.length];
}
document.write(jinrizhiban());
</script>

如果不想?yún)^(qū)分上下午,需將var days=parseInt(now.getTime()/12/3600/1000); 中的12改成24,然后在var pers=new Array中將數(shù)組由現(xiàn)在的14個(gè)(一天兩個(gè))改成7個(gè)(一天一個(gè))