javascript - How to set values for datepicker in jquery -
i have list of datepickers need set value based on selection of first date picker, if select value in first date picker same value should passed other date pickers
<input name="start" id='from' class="date-pick form-control" data-date-format="dd/mm/yyyy" type="text" /> <input name="start" id='to' class="date-pick form-control" data-date-format="dd/mm/yyyy" type="text" /> <input name="start" id='return' class="date-pick form-control" data-date-format="dd/mm/yyyy" type="text" /> <input name="start" id='depart' class="date-pick form-control" data-date-format="dd/mm/yyyy" type="text" />
here jquery
$('input.date-pick, .input-daterange input[name="start"]').datepicker().on('changedate', function (ev) { var date2 = $('.date-pick').datepicker('getdate', '+1d'); //alert (date2); date2.setdate(date2.getdate()+1); $('input.date-pick).datepicker('setdate', date2); });
but not working.please resolve
thanks in advance
$(function () { $("#datepicker1, #datepicker2, #datepicker3, #datepicker4").datepicker(); $("#datepicker1").datepicker("option", "onselect", function (datetext, inst) { var date1 = $.datepicker.parsedate(inst.settings.dateformat || $.datepicker._defaults.dateformat, datetext, inst.settings); var date2 = new date(date1.gettime()); date2.setdate(date2.getdate() + 1); $("#datepicker2").datepicker("setdate", date1); var date3 = new date(date1.gettime()); date3.setdate(date3.getdate() + 2); $("#datepicker3").datepicker("setdate", date1); var date4 = new date(date1.gettime()); date4.setdate(date4.getdate() + 3); $("#datepicker4").datepicker("setdate", date1); }); });
Comments
Post a Comment