Jquery UI datepicker,点击日期,获取日期并传递给 URL [英] Jquery UI datepicker, onclick of a date , get the date and pass to URL

查看:35
本文介绍了Jquery UI datepicker,点击日期,获取日期并传递给 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在事件页面(共享点页面)中有一个 jquery UI 日期选择器日历.

I have a jquery UI datepicker calendar in an event page(sharepoint page).

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

我需要在用户点击任何日期后获取日期并获取该日期并将其作为 mypage.aspx?dt=1/12/2012 传递到页面 url.我有这个但无法工作.

I need to get the date once user clicks on any date and get that date and pass it to the page url as mypage.aspx?dt=1/12/2012.I have this but not working.

$('.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();
        });

有人可以帮忙吗?

推荐答案

try

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

使用 onSelect 事件(此处记录)

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

Allows you to define your own event when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this refers to the associated input field.

这篇关于Jquery UI datepicker,点击日期,获取日期并传递给 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆