I have two datepickers. When start date is selected, end date is automatically assigned x days later through php. This works fine, but I have one problem. The jQuery code that does this job, I want it to be launched also when the page is refreshed/loaded (start date is saved in a php session). This is my code:
$(document).ready(function(){
$("#txtStartDate").datepicker({
onSelect: function(){
var datum = $(this).datepicker('getDate');
datum.setDate(datum.getDate() + <?php echo $nights; ?>);
$("#txtEndDate").datepicker("setDate", new Date(datum.getTime()));
}
});
$("#txtEndDate").datepicker();
});
I was thinking along the lines of using “onSelect, onLoad: funct…”.
How is this achieved?
Create a seperate function to set end date, then call it on onLoad event.
then
<body onLoad="setEndDate();">