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

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

问题描述

我在事件页面中有一个jquery UI日期戳记日历(共享页面)。

  $('#datepicker')。datepicker(); 

一旦用户在任何日期点击并获得该日期并将其传递给页面网址为mypage.aspx?dt = 1/12 / 2012.我有这个但不工作。

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

这两种都不工作。



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

有人可以帮忙吗?

解决方案

尝试

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

使用 onSelect 事件(记录在这里


允许您定义自己的选择datepicker时的事件。该函数接收选定的日期作为文本,并将datepicker实例作为参数。这是指相关的输入字段。



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

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

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;
        });

Neither is this working..

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

can someone help?

解决方案

try

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

uses the onSelect event (documented here)

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,onclick的日期,获取日期并传递给URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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