php做可多選擇的checkbox日曆

今天要求做考覈系統,然後可以複選設置當月的休息時間

<table width="50%" border="0" cellpadding="8" cellspacing="0" class="list_tab">
    <tr>
        <th class="tc"><input onclick="selectAllbyjz(this)" class="1" value="" type="checkbox"> 日</th>
        <th class="tc">一</th>
        <th class="tc">二</th>
        <th class="tc">三</th>
        <th class="tc">四</th>
        <th class="tc">五</th>
        <th class="tc"><input onclick="selectAllbyjz(this)" class="7" value="" type="checkbox"> 六</th>
    </tr>
    <?php
    //填補前面空白
    $start_week = date('w', strtotime(date('Y-m-1')));
    $start_week_html = '';
    for($i=0;$i<$start_week;$i++){
        $start_week_html .= '<td></td>';
    }
    echo '<tr>';
    $i7 = 0;
    for ($d=1;$d<=date('t');$d++){
    if($d==1){echo $start_week_html;$i7=$start_week;}
    $i7++;
    $thisd = sprintf ('%02d',$d);
    ?>
    <td class="tc"><input class="<?=$i7?>" name="xiudate[]"  value="<?=$thisd?>" type="checkbox"> <?=$d?></td>
    <?php
    if($i7%7==0){echo '</tr>';$i7=0;}
    }
    //填補最後空白
    if($i7%7!=0){
    for($i=0;$i<(7-$i7);$i++){
    echo'<td></td>';
    }
    echo '</tr>';
    }
    ?>
    
</table>

做成效果如下圖

image.png

這樣就可以做一個簡單的日曆多選了

原文地址:http://www.codelovers.cn/article/20180621140757.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章