douliang4858
2015-12-08 17:38
浏览 23

日期选择器数据未发送到下拉列表

<?php

require '../common/pdo_connect.php';
try{
  $stmt = $db->query("SELECT date FROM disabledate");
  $db_ddates = $stmt->fetchAll(\PDO::FETCH_ASSOC);

  $js_ddates = "";
  foreach ($db_ddates as $row => $record) {
    $js_ddates .= '"' . $record['date'] . '",';
  }

}
catch(\PDOException $e) {
  echo $e->getMessage();
}

   ?>


                <label>Pick a date

                <input
                    id="drop1"
                    class="datepicker"
                    name="drop1"
                    type="text"
                    value=""
                    data-value="">

                    </label>




        <div id="container"></div>





    <script src="datepicker/tests/jquery.1.9.1.js"></script>
    <script src="datepicker/lib/picker.js"></script>
    <script src="datepicker/lib/picker.date.js"></script>
    <script src="datepicker/lib/legacy.js"></script>



    <script type="text/javascript">
    //datepicker
    // take dates as array of strings from db
var ddates_str_arr = [ <?php echo $js_ddates; ?> ];
// build dates array for picker
var disdates = [];
for (var i = 0; i < ddates_str_arr.length; i++) {
  disdates.push(new Date(ddates_str_arr[i]));
}

var $input = $( '.datepicker' ).pickadate({
  formatSubmit: 'yyyy/mm/dd',
  min: true,
  container: '#container',
  // editable: true,
  closeOnSelect: true,
  closeOnClear: false,
  disable: disdates
});


        var picker = $input.pickadate('datepicker')
    </script>



<script src="jquery-1.9.0.min.js"></script>







        <div class="cascade" id="products"></div> 
          <div id="employees" class="cascade"></div> 
           <div id="res_time" class="res_time"></div> 
        </div>



        <div class="contact-right1">
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <button id="save" class="button_example">Done</button></div>
        </form>
    </div>
  </div>
<script src="jquery-1.9.0.min.js"></script>
<script>
$(document).ready(function(){
$("#savecascade").submit(function(){
var get_data=$("#savecascade").serialize();
$.ajax({
            type: "POST",
            url: "inser_data.php",
            data: {"csc":get_data},
            cache: false,
            success: function(html) {    
                alert(html);
            }
        });
return false;
});

change(function(){

    var categories_id =  picker; 
// alert(categories_id);    
    $("#products").html( "" );
    $("#employees").html( "" );
    $("#res_time").html( "" );



     $.ajax({
            type: "POST",
            url: "fetch_products.php",
            data: "categories_id="+categories_id,
            cache: false,
            beforeSend: function () { 
                $('#products').html('<img src="loader.gif" alt="" width="24" height="24">');
            },
            success: function(html) {    
                $("#products").html( html );
            }
        });
    } 
});
});
</script>
</body>
</html>

forgive my messy code, i have a chained ajax box, it's not going to the second box because i put a date picker first, why the second drop down doesnt work? i guess im not sending the data from it. how to send the data to fetch_products.php

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanbin4847 2015-12-08 18:07
    已采纳

    try:

    $.ajax({
                type: "POST",
                url: "fetch_products.php",
                data: {categories_id:$('#drop1').val()},
                cache: false,
                beforeSend: function () { 
                    $('#products').html('<img src="loader.gif" alt="" width="24" height="24">');
                },
                success: function(html) {    
                    $("#products").html( html );
                }
            });
        } 
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题