How do I get Date Range Picker to pass the selected date to my input text box or a variable?
in Using jQuery Plugins
•
8 years ago
My javascript below using preset ranges for DateRangePicker - I need to pass the selected start and end dates to two input boxes in LOGIXML called StartDate and EndDate. I am not sure how to do this. Please help.
Note: I don't want to run the daterangepicker logic for two different input fields(from and to). I want to use one input field but the start and end dates are passed to two separate variables.
I am using comiseo.daterangepicker js. Please help.
$(document).ready(function() {
$("#inpDatePicker").daterangepicker({
presetRanges: [{
text: 'Today',
dateStart: function() { return moment() },
dateEnd: function() { return moment() }
}, {
text: 'Month to Date',
dateStart: function() { return moment().startOf('month') },
dateEnd: function() { return moment() }
}, {
text: 'Quarter to Date',
dateStart: function() { return moment().startOf('quarter') },
dateEnd: function() { return moment() }
}, {
text: 'Year to Date',
dateStart: function() { return moment().startOf('Year') },
dateEnd: function() { return moment() }
}],
applyOnMenuSelect: true,
datepickerOptions: {
minDate: 0,
maxDate: null,
numberOfMonths : 3,
changeMonth: true,
changeYear: true
}
})
});
I tried the following script but it didn't give me the results i was hoping for:
- $('#inpStartDate,#inpEndDate').daterangepicker({ datepickerOptions : {
- numberOfMonths : 2
- }
- });
The results is:
The results above is NOT what I want to see...I want to see the following:
Start Date: Jan 1, 2014 and End Date: Dec 18, 2014. How do I achieve this?
1