Setdate onSelect Datepicker

时间:2012-03-03 14:20:53

标签: jquery events datepicker

setDate事件触发第一个文本元素时,我可以onSelect另一个文本元素吗?

我尝试用这种方式编码,它不起作用:

$( "#datebilled" ).datepicker({
    showOn: "both",
    buttonImage: "images/calendar.gif",
    buttonImageOnly: true,
    changeMonth: true,
    changeYear: true,
    beforeShowDay: noWeekendsOrHolidays,
    onSelect: function(date) {
        if ($('#cat option:selected').text() == "ABC") {
            var date_billed = $('#datebilled').datepicker('getDate');
            var date_overdue = new Date();
            var weekDays = AddBusinessDays(45);

            date_overdue.setDate(date_billed.getDate() + weekDays);
            date_overdue = $.datepicker.formatDate('mm/dd/yy', date_overdue);

            //setDate of date overdue
            $('#datepd').datepicker('setDate', date_overdue);


        }
    }
});

1 个答案:

答案 0 :(得分:3)

使用onSelect事件

$('.selector').datepicker({
   onSelect: function(dateText, inst) {
       $("#ElemID").val(dateText);

   }
});

DEMO