views:

293

answers:

2

I have a datepicker with changeyear: true. The 'year' drop down displays the title as 2009, then instead of the next year below the title being 2008, 2007, 2006 and so on it starts at 1999 and counts upwards. I can't seem to find an easy solution to reverse this order?

A: 

You can directly change the order of the select options after the select has been created. Keep in mind, though, that you're tooling around with jQuery-controlled elements, so you need to be careful when mucking around.

var opts = $('select.ui-datepicker-year option');
$('select.ui-datepicker-year').html('');
opts.each(function()
{
    $('select.ui-datepicker-year').prepend(this);
});

You'll then have to correctly set which year is selected by default. Also remember that you'll have to run this code every single time a datepicker is shown.

Matt Ball
A: 
Cuong Quach
thats exactly what I was after thank you very much!
Lance