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
Post a Comment