开发者

Jquery -2 datepickers won't GET or POST

I have 2 date pickers for Start date and End date... Could someone tell me why this does not POST anything to the DIV...

$(function () {
    var start1 = $('#start1');
    var end1 = $('#end1');

    start1.datepicker({
        onClose: clearEndDate
    });
    end1.datepicker({
        beforeShow: setMinDateForEndDate
    });

    function setMinDateForEndDate() {
        var d = start1.datepicker('getDate');
        if (d) return {
            minDate: d
        }
    }

    function clearEndDate(da开发者_如何学编程teText, inst) {
        end1.val('');
    }
    $(function get() {
        $('#start1').daterangepicker({
            onSelect: function (dateText, inst) {
                $.post("report.php", {
                    dt_start: dateText
                }, function (data) {
                    $("#genreport").html(data);
                });
            }
        });
        $('#end1').daterangepicker({
            onSelect: function (dateText, inst) {
                $.post("report.php", {
                    dt_end: dateText
                }, function (data) {
                    $("#genreport").html(data);
                });
            }
        });
    });
});

The Datepickers open and I can select a date. The date shows in the box, but it does not GET or "post" anything to the DIV tag... I get nothing.

Thank you

Alan


you are creating both datepickers twice:

start1.datepicker({
    onClose: clearEndDate
});

and then:

$('#start1').daterangepicker({

check it with firebug here: http://jsfiddle.net/KF9hb/12/


Fazo (in his answer) and I (in last comment with link jQuery datepicker, onSelect won't work) are suggesting the following.

    $('#start1').daterangepicker({
        onSelect: function (dateText, inst) {
            $.post("report.php", {
                dt_start: dateText
            }, function (data) {
                $("#genreport").html(data);
            });
        }

        onClose: clearEndDate

    });

rather than the two seperate places where you put start1.datepicker and $('#start1').datepicker, and similarly for end1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜