douguxun6866 2013-01-24 02:17
浏览 32
已采纳

从工作时间框架中减去午餐时间

I currently have a form that would ask a user specifically the working hours of businesses below is what I'm using.

<tr>
        <td colspan="2"><input type="radio" name="mon" value="1"> Monday with No Lunch Break</td>
        <td colspan="4"><input type="radio" name="mon" value="2"> Monday with  Lunch Break</td>
    </tr>
    <tr>
        <td>Start time :AM<input type="time"  name="mon_strt_1" class="hour_field"></td>
        <td>End time :PM<input type="time" name="mon_end_1" class="hour_field"></td>
        <td>Start time :AM<input type="time"  name="mon_strt_2a" class="hour_field"></td>
        <td>End time :AM<input type="time" name="mon_end_2a" class="hour_field"></td>
        <td>Start time :PM<input type="time" name="mon_strt_2b" class="hour_field"></td>
        <td>End time :PM<input type="time"  name="mon_end_2b" class="hour_field"></td>
    </tr>

As you see I asked the user if on Monday the business would have a lunch break if so he would fill out the proper field and also clicking on the radio button. I would like to ask any help on how to make things easier for the user. That once he entered a time frame Like 8:00am to 6:00pm then would enter the lunch break 12:00nn to 1:00pm upon submission would return WORKING HRS: 8:00am to 12:00nn , 2:00pm to 6:00pm, Here's a link for a plugin that I used but i can't manage to use it in multiple forms. Note that i would also set the time from tuesday to friday. then sat to sun.

  • 写回答

1条回答 默认 最新

  • dougaicha5258 2013-01-24 02:49
    关注

    very simple. html and javascript:

    <script>
    function disablebreaks(disable){
        document.getElementsByName('break_strt')[0].disabled=disable;
        document.getElementsByName('break_end')[0].disabled=disable;
    }
    </script>
    <form action="action.php" method="post">
    <input type="radio" name="mon_break" value="false" onchange="disablebreaks(true)" />No break
    <input type="radio" name="mon_break" value="true" onchange="disablebreaks(false)" />break
    <input type="time" name="mon_strt" />
    <input type="time" name="mon_end" />
    <input type="time" name="break_strt" />
    <input type="time" name="break_end" />
    </form>
    

    php in action.php:

    <?php
    echo $_POST['mon_break']?"working hrs: {$_POST['mon_strt']} to {$_POST['break_strt']}, {$_POST['break_end']} to {$_POST['mon_end']}":"working hrs: {$_POST['mon_strt']} to {$_POST['mon_end']}";
    ?>
    

    This is untested, tell me if errors occur.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?