title: Restrict Days In jQuery Datepicker using checkboxes
body: <p>I'd like to restrict the days in the jquery datepicker using checkboxes - I've managed so far to restrict days (hard coded) initially however am unsure how to proceed to make it dynamically change.</p>
  
  <p>Here's my code so far...</p>
  
  <pre><code>&lt;table id="selectdays"&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="checkbox" value="sun"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="mon"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="tue"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="wed"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="fri"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="sat"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" value="sun"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;input type="text" id="datepicker"&gt;
  
  
  $(function() {
      $( "#datepicker" ).datepicker({
          showOn: "button",
          buttonImage: "../images/calendar.jpg",
          buttonImageOnly: true,
          dateFormat: 'DD, MM d, yy',
          minDate: 0,
          beforeShowDay: nonWorkingDates,
  });
  
  function nonWorkingDates(date){
      var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
      var closedDays = [[Monday], [Tuesday]];
      for (var i = 0; i &lt; closedDays.length; i++) {
          if (day == closedDays[i][0]) {
              return [false];
          }
  
      }
      return [true];
  }
  
  });
  </code></pre>