title: How do I get date range picker to output value from visible input to separate hidden inputs?
body: <p>Can someone check my code?  I can't seem to get this working. I'm using date range picker and need the dates that appear in the main input that the user selects to also output into the hidden input fields. I need the hidden field format to be YYYY-MM-DD. </p>
  
  <p>HTML</p>
  
  <pre><code> &lt;input type="text" class="main" name="maininput" id="datesearch"&gt;
   &lt;input type="hidden" name="start" id="startdate"&gt;
   &lt;input type="hidden" name="end" id="enddate"&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$(function() {
  var start = moment().subtract(29, 'days');
  var end = moment();
  
  
  function cb(start, end) {
      $('#datesearch').html(start.format('YYYY/MM/DD') + ' - ' + end.format('YYYY/MM/DD'));
      $('#startdate').value = $('#datesearch').html(start.format('YYYY-MM-DD')).value;
      $('#enddate').value = $('#datesearch').html(end.format('YYYY-MM-DD')).value;
  }
  
  $('#datesearch').daterangepicker({
      startDate: start,
      endDate: end,
      timePicker: true,
      ranges: {
         'Today': [moment(), moment()],
         'This Month': [moment().startOf('month'), moment().endOf('month')],
          }
  
  
  
  }, cb);
  
  cb(start, end);
  
  });
  </code></pre>
  
  <p>Also, when I submit, I've noticed the calendar won't update the user selection and always defaults back to the startDate and endDate values...</p>