views:

17

answers:

2

Hi,

I would like to add links on every date in my calendar. For example, if I click on the 25 august 2010, I would like that the page gets redirected to : xxxxxx/25082010/

(ddmmyyyy)

The plugins is this one : http://keith-wood.name/datepick.html

I can add an event when a date is selected (onSelect) but I can't get the date in the good format (ddmmyyyy) and the link to be made.

<script type='text/javascript' >
    $(document).ready(function(){

$('#mindate').datepick({
    dateFormat: 'yyyy-mm-dd',
    defaultDate: '2010-10-01',
    minDate: '2009-10-01', 
    maxDate: '2010-10-01',
    onSelect: function(dates) { alert('The chosen date(s): ' + dates); }, 
    showTrigger: '<button type="button" class="trigger">Change</button>'});

});
</script>

The "onSelect" give me the date like this: The chosen date(s): Wed Aug 25 2010 00:00:00 GMT-0400 (Eastern Daylight Time)

Thanks

A: 

I'd switch to jQuery UI datepicker if it's not too late, that script has far better support and features http://jqueryui.com/demos/datepicker/ And it has different types of dates and parseDate method.

zarko.susnjar
+1  A: 

You can use some of the built-in methods on the Date object to format the date that the picker is returning:

alert('The chosen date(s): ' + dates.getDate() + 
                               dates.getMonth() + 
                               dates.getYear());
Ryan Brunner
This ain't working
Jean-Nicolas
Can you check your javascript console to see if an error is being thrown? It's possible that the plugin is returning a string representation of the date rather than the actual date. If that's the case, you can parse `dates` into a date variable using `new Date(dates)` and then use the methods described above.
Ryan Brunner