Javascript Calendar.setup获取选定日期

时间:2014-01-22 02:51:10

标签: javascript jquery html calendar

我正在编辑现有系统,他们正在使用Calendar.setup而不是jquery datepicker。我已经建议datepicker比calendar.setup更高级,但是,他们仍然希望使用calendar.setup。

我的问题是,我不知道如何获得所选日期的值。

 Calendar.setup
    (
        {
            inputField  : 'txtDate',       // ID of the input field
            ifFormat    : "%Y-%m-%d",       // The Date Format
            button      : 'txtDate'      // ID of the button
        }
    );

2 个答案:

答案 0 :(得分:1)

试试这个:

 Calendar.setup
    (
        {
            inputField  : 'txtDate',       // ID of the input field
            ifFormat    : "%Y-%m-%d",       // The Date Format
            button      : 'txtDate',      // ID of the button
            onSelect    : function(){
                              var calDate = this.selection.get();
                              var calHours = new String(this.getHours());
                              var calMinutes = new String(this.getMinutes());
                              var calTime = ((calHours.length == 1) ? '0'+calHours : calHours) + ((calMinutes.length == 1) ? '0'+calMinutes : calMinutes );
            }
        }
    );

答案 1 :(得分:0)

var cal=Calendar.setup
    (
        {
            inputField  : 'txtDate',       // ID of the input field
            ifFormat    : "%Y-%m-%d",       // The Date Format
            button      : 'txtDate',      // ID of the button

        })
var seldate=cal.date