Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  161] [ 2]  / answers: 1 / hits: 53929  / 13 Years ago, wed, january 18, 2012, 12:00:00

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?


More From » jquery

 Answers
11

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.



[#87941] Tuesday, January 17, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mustafaericho

Total Points: 322
Total Questions: 103
Total Answers: 110

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
mustafaericho questions
Mon, May 31, 21, 00:00, 3 Years ago
Sun, May 23, 21, 00:00, 3 Years ago
Sat, Feb 13, 21, 00:00, 3 Years ago
Sat, Jan 2, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
;