title: If datepicker already has value run onselect anyway
body: <p>Currently, I can select a date and it fills my input fields with the date for 7 days and the corresponding day of the week in another series on input fields (just 3 days in example below).  This is working well, although I'm sure there is a more efficient way to write the same thing with arrays, I just have no idea.</p>
  
  <p>However, if I get the start date from the database on page load rather than selecting it with datepicker, it obviously doesn't trigger the onselect event and the fields don't populate.  How can I get it to populate the fields in both situations?  </p>
  
  <p>I was thinking a function that is run when either the datepicker input has a valid value or onselect, but having never really touched JS before this little project I'm in over my head.</p>
  
  <pre><code>$(function() {
  $("#StartDate").datepicker({
    dateFormat: 'dd/mm/yy',
    onSelect: function(dateStr, inst) {
        var weekday=new Array(7);
          weekday[0]="Monday";
          weekday[1]="Tuesday";
          weekday[2]="Wednesday";
          weekday[3]="Thursday";
          weekday[4]="Friday";
          weekday[5]="Saturday";
          weekday[6]="Sunday";
        var Date1 = $.datepicker.parseDate('dd/mm/yy', dateStr);
        Date1.setDate(Date1.getDate('dd/mm/yy'));
        $('#Date1').val(Date1.toLocaleDateString());
        $('#Day1').val(weekday[Date1.getUTCDay()]);
        var Date2 = $.datepicker.parseDate('dd/mm/yy', dateStr);
        Date2.setDate(Date2.getDate('dd/mm/yy') + 1);
        $('#Date2').val(Date2.toLocaleDateString());
        $('#Day2').val(weekday[Date2.getUTCDay()]);
        var Date3 = $.datepicker.parseDate('dd/mm/yy', dateStr);
        Date3.setDate(Date3.getDate('dd/mm/yy') + 2);
        $('#Date3').val(Date3.toLocaleDateString());
        $('#Day3').val(weekday[Date3.getUTCDay()]);
        }
    });
  });
  </code></pre>