Middle-Level Middle-Level - 7 months ago 15
HTML Question

Display "End Date" based on datepicker "Start Date" and inputted date

Need answer as soon as possible!

How to get a end date based on a inputted day interval and start date like if i have a start date that has a value of

4/19/2015
and the then the inputted day interval is like
10
how would I do that in jquery and the event will trigger if the value inside the datepicker input box changed.

Guys I will appreciate all your help T_T.

Answer

you may refer to the answer How to add number of days to today's date?

Assuming, you are using jqueryui datepicker. if so, use following code to get the selected date, as soon as the date is selected from the datepicker.

<script>
  $(function() {
    $( "#from" ).datepicker({
      onSelect: function( selectedDate ) {
        var startDate = selectedDate; // you got the startDate here
      }
    });
  });
 </script>
Comments