jquery.datePicker example: karmasAgent demo

< date picker home

The following example was written to answer this support request.

Note

This will by default only allow you to select months in the future as the default startDate (e.g. first selectable date) is today. You can also pass a startDate in to the call to datePicker if you want to be able to select months in the past.

Or if it was your intention to only allow dates from a given month to be selected then check out this example

Page sourcecode

$(function()
{
	$('#monthsList li').each(
		function()
		{
			$this = $(this);
			var monthBits = $this.html().split('/');
			
			$this
				.datePicker(
					{
						createButton:false,
						month:Number(monthBits[0])-1, // JS months start from 0 not 1...
						year:Number(monthBits[1])}
				)
				.bind(
					'click',
					function()
					{
						$(this).dpDisplay();
						this.blur();
						return false;
					}
				)
				.bind(
					'dateSelected',
					function(e, selectedDate, $td)
					{
						Date.format = 'yyyymmdd';
						// alert the URL
						alert('http://www.myURL.com/section/' + selectedDate.asString());
						// reassign the date format back to how you want it.
						Date.format = 'dd/mm/yyyy';
					}
				);
		}
	)
});

Page CSS

/* Make it so that dates from other months don't show up */	
td.other-month {
	visibility: hidden;
}