JQuery DatePicker - pop calendar dialog on 'OnSelect' of another datepicker

Posted by sajanyamaha on Stack Overflow See other posts from Stack Overflow or by sajanyamaha
Published on 2012-10-18T04:58:15Z Indexed on 2012/10/18 5:00 UTC
Read the original article Hit count: 421

Filed under:
|

I have two JQuery datepickers to select 'StartDate' and 'EndDate'.My requirement is to automatically popup the end date calendar after startDate has been selected.

I have tried all the steps in COMMENTED HERE.

The code here succesfully triggers the focus of 'EndDate' calendar,but it displays for a second and hides off.

$(document).ready(function() {  //Runs when tab is loaded
        var dateFormat = "dd/mm/yy";
        var today=new Date();
        today.setMonth(today.getMonth()-1); 
        $("#ctl00_ContentPlaceHolder1_datepicker1").datepicker({
         minDate: 0, 
         dateFormat:dateFormat,
         //maxDate: '+12M +31D',  
         onSelect: function(dateText, inst){
                   var the_date = new Date($.datepicker.parseDate(dateFormat,dateText));
                   //var end=(the_date.getDate()+1) + '/' + (the_date.getMonth()+1) + '/' + the_date.getFullYear();
                   $("#ctl00_ContentPlaceHolder1_datepicker2").datepicker('option', 'minDate', the_date);
                  // TRIED ALL THESE
                  //document.getElementById('ui-datepicker-div').style.display  = 'block';
                  //document.getElementById('ui-datepicker-div').style.left  = '635.5px';
                  //$("#ctl00_ContentPlaceHolder1_datepicker2").datepicker("show");
                  //$("#ctl00_ContentPlaceHolder1_datepicker2").datepicker(); 
                  //$("#ctl00_ContentPlaceHolder1_datepicker2").focus();
                  //$('#foo').slideUp(300).delay(800).fadeIn(400);
                  //$("#ctl00_ContentPlaceHolder1_datepicker2").trigger("focus"); 
                  $('#ctl00_ContentPlaceHolder1_datepicker2').focus();

      }
     });
     $("#ctl00_ContentPlaceHolder1_datepicker2").datepicker({
        //maxDate: '+12M +31D', 
        dateFormat:dateFormat,
        onSelect: function(dateText, inst){

        }                       
    });

 });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about datepicker