【问题标题】:Jquery UI datepicker, onclick of a date , get the date and pass to URLJquery UI datepicker,点击日期,获取日期并传递给 URL
【发布时间】:2012-02-13 07:50:58
【问题描述】:

我在活动页面(共享点页面)中有一个 jquery UI datepicker 日历。

$('#datepicker').datepicker();

一旦用户单击任何日期并获取该日期并将其作为 mypage.aspx?dt=1/12/2012 传递给页面 url,我需要获取日期。我有这个但不工作。

$('.ui-datepicker td a').click(function(){  
        var url=$(location).attr('href');
        var date = $(this.datepicker( "getDate" ));
                if(date != 'null')
            url += '&dt=' + date;           
        window.location.href=url;
        });

这也不行..

$('.ui-datepicker td a').click(function() { 
        window.location.href = 'http://mysite/events/Pages/default.aspx?dt=' + $('#datepicker').datepicker().val();
        });

有人可以帮忙吗?

【问题讨论】:

    标签: javascript jquery date user-interface datepicker


    【解决方案1】:

    试试

    $('#datepicker').datepicker({
        onSelect: function(dateText, inst) { 
            window.location = 'http://mysite/events/Pages/default.aspx?dt=' + dateText;
        }
    });
    

    使用onSelect 事件 (documented here)

    允许您在选择日期选择器时定义自己的事件。该函数接收选定的日期作为文本和 datepicker 实例作为参数。 this 指的是关联的输入字段。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多