title: JQuery Datepicker: put week number in the input box instead of selected day
body: <p>I am very new to JQuery and JS and I wrote a small GUI in php where the user has to choose two  week numbers and I have a function that produces some stats about it. I found a JS code that highlights the whole week when the user go through it but when clicking on one of the dates, the specific date is being inserted to the input box. I would like to put the week number in the input box instead. Is this possible?</p>
  
  <p>The code I use was posted here: 
  <a href="http://jsfiddle.net/MqD2n/" rel="nofollow noreferrer">http://jsfiddle.net/MqD2n/</a></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css"&gt;
  &lt;script type="text/javascript"&gt;
  $(function() {   
      var startDate;
      var endDate;
  
      var selectCurrentWeek = function () {
          window.setTimeout(function () {
              $('.ui-weekpicker').find('.ui-datepicker-current-day a').addClass('ui-state-active').removeClass('ui-state-default');
          }, 1);
      }
  
      var setDates = function (input) {
          var $input = $(input);
          var date = $input.datepicker('getDate');
          if (date !== null) {
              var firstDay = $input.datepicker( "option", "firstDay" );
              var dayAdjustment = date.getDay() - firstDay;
              if (dayAdjustment &lt; 0) {
                  dayAdjustment += 7;
              }
              startDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - dayAdjustment);
              endDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - dayAdjustment + 6);
  
              var inst = $input.data('datepicker');
              var dateFormat = inst.settings.dateFormat || $.datepicker._defaults.dateFormat;
              $('#startDate').text($.datepicker.formatDate(dateFormat, startDate, inst.settings));
              $('#endDate').text($.datepicker.formatDate(dateFormat, endDate, inst.settings));
          }
      }
  
      $('.week-picker').datepicker({
          beforeShow: function () {
              $('#ui-datepicker-div').addClass('ui-weekpicker');
              selectCurrentWeek();
          },
          onClose: function () {
              $('#ui-datepicker-div').removeClass('ui-weekpicker');
          },
          showOtherMonths: true,
          selectOtherMonths: true,
          onSelect: function (dateText, inst) {
              setDates(this);
              selectCurrentWeek();
              $(this).change();
          },
          beforeShowDay: function (date) {
              var cssClass = '';
              if (date &gt;= startDate &amp;&amp; date &lt;= endDate)
                  cssClass = 'ui-datepicker-current-day';
              return [true, cssClass];
          },
          onChangeMonthYear: function (year, month, inst) {
              selectCurrentWeek();
          }
      });
  
      setDates('.week-picker');
  
      var $calendarTR = $('.ui-weekpicker .ui-datepicker-calendar tr');
      $calendarTR.live('mousemove', function () {
          $(this).find('td a').addClass('ui-state-hover');
      });
      $calendarTR.live('mouseleave', function () {
          $(this).find('td a').removeClass('ui-state-hover');
      });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;input class="week-picker"&gt;&lt;/input&gt;
      &lt;br /&gt;&lt;br /&gt;
      &lt;label&gt;Week :&lt;/label&gt; &lt;span id="startDate"&gt;&lt;/span&gt; - &lt;span id="endDate"&gt;&lt;/span&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>