0

I have a Jquery Datepicker where i need to select a date range, like the start date and end date. Currently I am passing (individual) selected date on a click of a button. I need some understanding how can i pass the date range.

Jquery Calender (Datepicker)

function showSelectDatesFromCalendar() {
    $('#selectDates').datepick({minDate: new Date(1990, 1 - 1, 1),maxDate: new Date(), defaultDate: new Date(), monthsToShow:[1,3],monthsToStep:3, multiSelect:999,dateFormat:'mm/dd/yyyy'
        ,changeMonth:false, showSpeed:'#fast'});
}

1) If I select 1 dec and 30 dec, 1 dec is start date, 30 dec is end date. then it should pass all the dates in between the start and end date.

How can i achieve this functionality.

S Jagdeesh
  • 1,305
  • 2
  • 25
  • 45

2 Answers2

1

In DatePicker setting

Check for "rangeSelectSet" and set it to "true" to allow the selection of a date range in the datepicker.

The first selected date is the start of the range and the second selected date is the end of the range. You can Set to "false" to select a single date.

reference

function showSelectDatesFromCalendar() {
    $('#selectDates').datepick({minDate: new Date(1990, 1 - 1, 1),maxDate: new Date(), defaultDate: new Date(), monthsToShow:[1,3],monthsToStep:3, multiSelect:999,dateFormat:'mm/dd/yyyy'
        ,changeMonth:false, showSpeed:'#fast', rangeSelect:true,});
}

Check the Modified code.

RakeshSharma
  • 191
  • 4
0

You need to work with callbacks to manually assign / change things.

$('.selector').datepicker({
   onSelect: function(dateText, inst) { 
     //  your modification here.
   }
});

See the Events tab on http://jqueryui.com/demos/datepicker/

EDIT: See Proper way to add a callback to jQuery DatePicker, they are providing large examples for things.

Community
  • 1
  • 1
pdu
  • 9,917
  • 4
  • 53
  • 87
  • http://keith-wood.name/datepick.html "Unlimited" dates: tab I am exactly using the same Jquery library. Rather than selecting multiple dates, i would like to chose only start and end date and every dates in between should automatically be selected. – S Jagdeesh Jan 18 '12 at 09:07