PHP Javascript Codeigniter datepicker condition -


i have drop down list linked datepicker..but want make condition on datepicker,if dropdownlist value selected year (ex. 2017),then datepicker shows 2017 date.it cant changed 2016 or 2018.here of code example.

**php view** <select name ="year" id="year" class="form-control select2">  <?php foreach($year $value)   {    echo "<option value="$value['id_year'].">".$value['year']."</option>"   } </select> <input type="text" name="date" id="date" class="form-control">  **javascript** $('$date').datepicker({     format : "yyyy-mm-dd",     autoclose:true }) 

how did put condition based on selected year ? thank you...

you need watch changes on select input, set max , min date of datepicker

$('#year').on('change',function(){    var year = $(this).val();   $('#date').datepicker( "option", "mindate", new date(year, 0, 1) );  $('#date').datepicker("option","maxdate", new date(year,11,31)); }); 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -