jQuery UI Datepicker go to date URL

2019-07-20 01:04发布

问题:

Does anyone know if it is possible to use the jQuery UI Datepicker, and when clicking on a date, set the document.location to that date, appended to a preset URL?

So, if I clicked on one of the dates, it might direct me to:

http://www.mysite.com?date=2009-10-25

I need to just use this as a quick way to quickly navigate my website calendar.

Ideas?

回答1:

Just give it an onSelect function to call.



回答2:

I did small example, it works for me just change date format :)

$().ready(function(){  
    $('#datepicker').click(function(){
        window.location.replace("http://www.mysite.com/?date=" + $('#datepicker').val());
    });
});


回答3:

I assume you download datapicker from Jqueryui.com with examples so you can get choosen date from calendar with:

$('#datepicker').val()

so paste it in onclick() function or onchane() function