Changing startDate and endDate params of BootStrap Datepicker on change of a select Box

谁说我不能喝 提交于 2019-12-01 10:41:03

Change the values of option 2013-2014 and 2015-2016 like

<select id="mySelect">
    <option value="2012-2013">2012-2013</option>
    <option value="2013-2014">2013-2014</option>
    <option value="2015-2016">2015-2016</option>
</select>

Change this to js,

var myStartDt;
function mydatepicker(){
   myStartDt= $('#myStartDate')
        .datepicker({
        startDate: getStartDate(),
        endDate: getEndDate()
    }).on('changeDate', function (ev) {
        myStartDt.hide();
    }).data('datepicker');
}
 $("#mySelect").on('change',function(){
    // alert(this.value)
    $('#myStartDate').datepicker("remove");
    mydatepicker();//$('#id-element').datepicker("destroy");
});
mydatepicker();

Fiddle

I think you can simply use setStartDate and setEndDate methods: http://jsfiddle.net/ivkremer/fRzyL/21/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!