I have a form with Jquery Datepicker and i can save the date in the database.
But when i reload the form to update the datas, i would like to have Jquery Datepicker showing the date previoulsy recorded in the database.
I can load it with php. I just need to update the datepicker.
In the documentation, i see :
beforeShowType: Function( Element input, Object inst ) Default: null A function that takes an input field and current datepicker instance and returns an options object >to update the datepicker with. It is called just before the datepicker is displayed.
I think it can be the solution. Could someone give me an example ?
What did you attach the datepicker to? If you attached it to an input, then you just need to set the value of the input before calling datepicker() on it.
If you haven't initialized the datepicker yet, you can do:
$( '#yourElement' ).datepicker({ defaultDate: yourDate });
Otherwise, you can call the setDate method to set the date on an already initialized datepicker:
$( '#yourElement' ).datepicker( 'setDate', yourDate );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With