Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to use datepicker apply to send a get request

             $(document).ready(function(){
                $('.daterange-btn').daterangepicker(
                    {
                        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')]
                        },
                        startDate: moment().subtract(29, 'days'),
                        endDate  : moment(),
                    },
                    function (start, end) {
                        $('.daterange-btn').find('span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
                        handleFilterEvent(start,end);
                    }
                )
                function handleFilterEvent(startDate = null,endDate = null){
                    var url = "https://www.google.com"+'?';
                    var startDate = startDate ? startDate.format('YYYY-MM-DD') : '';
                    var endDate = endDate ? endDate.format('YYYY-MM-DD') : '';
                    var params = {};
                    if(startDate && endDate){
                        params.start_date =  startDate;
                        params.end_date =  endDate;
                    }
                    url+= jQuery.param( params );
                    location.href = url;
                }
            });
Comment

PREVIOUS NEXT
Code Example
Javascript :: mock click function functinal component enzyme 
Javascript :: js.l16 
Javascript :: js how to get element csswidth 
Javascript :: how to transform object in string with scaped 
Javascript :: rivets js bind 
Javascript :: redireccionar a una página con javascript después de un tiempo 
Javascript :: typeracer 
Javascript :: apar chinmoy phy js code 
Javascript :: setTilme out js 
Javascript :: access multiple classes with loop 
Javascript :: What Is A ReadableStream 
Javascript :: javascript desktop app 
Javascript :: primeng browseranimationsmodule 
Javascript :: how to change owl nav, how to make custom next-prev button in owl carusol 
Javascript :: options not working properly in reactjs 
Javascript :: cannon js parent child 
Javascript :: javascript push 
Javascript :: intellij debugger export object as json 
Javascript :: jqerrt get all img alt from string 
Javascript :: beanstalk nodejs default port 
Javascript :: js get files 
Javascript :: client.login(email, password) discord.js 
Javascript :: check internet connection in react 
Javascript :: js set visibility 
Javascript :: toastr hides away quickly 
Javascript :: how to check invalid control angular formcontrol name 
Javascript :: javascript const 
Javascript :: react qurery jest test mock queryClientProvider 
Javascript :: js array reduce error not a function 
Javascript :: twhat is a js promise 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =