views:

3355

answers:

2

I'm using this jQuery inline datePicker plugin sample but I don't know how to set up default date selected. Do you have any idea?

+1  A: 

Here: http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerDefaultToday.html

$(function() {
     var date = new Date(); // replace with your date
     $('.date-pick').datePicker().val(date.asString()).trigger('change');
});

OR

Set date in your field:

<input class="date-pick" type="text" value="1/1/2009" />
Koistya Navin
this is possible when the datepicker is linked to a input, but my inline datepicker is linked to a div.:( I still don't know how to do it.
dole doug
ok, than use the first approach with .val('1/1/2009').trigger('change');
Koistya Navin
you cannot assign a value attribute to a div tab!
dole doug
+3  A: 

$('.date-pick').datePicker({ defaultDate: $.datepicker.parseDate("d m y", "31 8 2009") })

Philippe Rathé
It also seems to accept simple strings and interpret them intelligently. For example, this sets the default date to 2 months in the past: `... defaultDate: "-2m" ...` however, it doesn't seem to actually *select* the date. It just makes sure to display that date's month when the calendar popup appears.
Dan