编程爱好者之家

php做可多选择的checkbox日历

2018-06-21 14:08:42 715

今天要求做考核系统,然后可以复选设置当月的休息时间

<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

这样就可以做一个简单的日历多选了

同类文章