即时反映基于选择的日期差异(以周为单位)


Reflecting date difference in weeks based on selection instantly

你好,我有一个表单,用户可以在其中输入他们的租赁开始日期和结束日期。从这里开始,将有一个租赁期字段,以周的形式即时反映租赁开始日期和结束日期之间的差异

但我一直纠结于如何处理这个问题。有人有主意吗?使用HTML5输入日期btw.

<form id="form1" name="form1" method="post" action="rental.php">
        <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" /><br>
       <strong>  Start Date: </strong><input type="date"  value="" /> <br>     
         <strong>  End Date: </strong> <input type="date"value=""/><br>   
            <strong>Renting Period: </strong> <input type="text"  value="" readonly> <br>                                                                                                              
        <input type="submit" class="btn btn-danger" id="button" value="Rent It"> 
      </form>   

如果您想在客户端完成,您必须使用javaScript

研究javascript,jquery也会让这变得更容易,这样你就可以创建一个在更改时触发的函数。