This is an amazing date range picker for bootstrap templates but it doesn't come with any sample code for posting back to your webpage, the developer assumes everyone is a javascript expert.
Here is code to display the date range picker and post the information back the page on the querystring. <script type="text/javascript"> $(function() { var start = moment().subtract(29, 'days'); var end = moment(); function cb(start, end) { $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); //alert("A new date range was chosen: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); //window.location.href = "/activity.html?start=" + start.format('YYYY-MM-DD') + '&end=' + end.format('YYYY-MM-DD')); } $('#reportrange').daterangepicker({ startDate: start, endDate: end, ranges: { 'Today': [moment(), moment()], 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 'This Month': [moment().startOf('month'), moment().endOf('month')], 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } }, cb); cb(start, end); $('#reportrange').on('apply.daterangepicker', function (ev, picker) { //console.log(picker.startDate.format('MM/DD/YYYY')); //console.log(picker.endDate.format('MM/DD/YYYY')); window.location = "activity.html?s=" + picker.startDate.format('MM/DD/YYYY') + "&e=" + picker.endDate.format('MM/DD/YYYY') }); }); </script> Comments are closed.
|
2016-17 WorkExamples of my new work in 2016 and 2017 Archives
January 2018
Categories |