预订脚本中的实时可用性检查

时间:2019-05-29 01:08:37

标签: jquery

对于一个小的汽车预订脚本,我想用PHP,MySQL以及可能的Jquery创建一个实时解决方案。

在表格中,可以选择日期,开始时间和结束时间以及车牌号。

根据选择,脚本需要实时提供在选定日期和选定时间之间是否有可用汽车(或无汽车)的信息。


 <form method="POST" action="<? echo $_SERVER['PHP_SELF']; ?>">
        Op <input type="date" style="color:black;font: 14px arial, verdana, sans-serif;" name="datum" <? echo $required; ?>>&nbsp;


         <?
         // VAN
         echo "<select style=\"color:black;font: 14px arial, verdana, sans-serif;\"  name=\"van\" $required>";  
         echo "<option value = ''>van</option>";

         $tijdsaanduiding="";
         $tijd='';    

        for ($tijd = 0; $tijd <= 60; $tijd++) {
        $date='';
        $kwart='';
        $kwart=15 * $tijd;
        $comparetime=''; 

        $date = date('H:i', strtotime('08:00:00 + '.$kwart.' minutes') );
        $now=date('Y-m-d');
        $time=date('H:i');


        echo "<option value=\"$date\" $selected1>$date</option>";

        }
        echo "</select>";


        echo "&nbsp;";


        // TOT
        echo "<select style=\"color:black;font: 14px arial, verdana, sans-serif;\" name=\"tot\" $required>";  
         echo "<option value = ''>tot</option>";

         $tijdsaanduiding="";
         $tijd='';    

        for ($tijd = 0; $tijd <= 60; $tijd++) {
        $date='';
        $kwart='';
        $kwart=15 * $tijd;
        $comparetime=''; 

        $date = date('H:i', strtotime('08:00:00 + '.$kwart.' minutes') );
        $now=date('Y-m-d');
        $time=date('H:i');


        echo "<option value=\"$date\" $selected1>$date</option>";

        }
        echo "</select>";
       ?>

        bestuurder 
        <select style="color:black;font: 14px arial, verdana, sans-serif;" name="bestuurder" <? echo $required; ?>>
            <option value="bestuurder">Naam van de bestuurder</option>
        </select>
<br/><br/>



        <script>
        var $dropdown1 = $("select[name='van']");
        var $dropdown2 = $("select[name='tot']");

        $dropdown1.change(function() {
        $dropdown2.empty().append($dropdown1.find('option').clone());
        var selectedItem = $(this).val();
        if (selectedItem) {
            $dropdown2.find('option[value="' + selectedItem + '"]').remove();
            }
        });


        </script>




<input type="submit" value="Beschikbaarheid controleren" name="submit">
</form>

0 个答案:

没有答案