0

我有两个 JQuery 日期选择器来选择'StartDate' 和 'EndDate' 。我的要求是在选择 startDate 后自动弹出结束日期日历。

我已经尝试了 COMMENTED HERE 中的所有步骤。

这里的代码成功触发了'EndDate'日历的焦点,但它显示了一秒钟并隐藏起来。

$(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){

        }                       
    });

 });

WEBSITE 这里是前端http://www.chuttitime.com/beta/

4

2 回答 2

2

用这个 :

onClose: function() {
                  $('#endDate').focus();
            }});
于 2012-10-18T05:10:14.997 回答
0

可能这很有用..它有 2 个字段来指示范围http://jqueryui.com/datepicker/#date-range

于 2012-10-18T05:10:56.430 回答