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

后端 未结 2 490
面向向阳花
面向向阳花 2021-01-15 12:26

What I am trying to do :

I am trying to set the startDate and endDate params depending on the current value of year. I think that currenty what I have just sets the

相关标签:
2条回答
  • 2021-01-15 12:34

    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

    0 讨论(0)
  • 2021-01-15 12:56

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

    0 讨论(0)
提交回复
热议问题