Created
August 26, 2019 11:20
-
-
Save mshoaibdev/193a1773a1d2c9390855fa36351f3f47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#end_date").datepicker({ | |
minDate: 0, | |
// maxDate: (interval-1), | |
onSelect: function (date, inst) { | |
var start_date = new Date($('#start_date').val()); | |
var end_date = new Date(date); | |
days = 24 * 60 * 60 * 1000; | |
tempStartDate = start_date; | |
diffDays = Math.round(Math.abs((start_date - end_date) / (days))); | |
$('.date_times_left').empty(); | |
$('.date_times_right').empty(); | |
var index; | |
for (index = 0; index <= diffDays; index++) { | |
var parentElLeft = $('.start_end_timings').find('.date_times_left'); | |
var startTimeLast = $('.start_end_timings').find('.start_time.clone'); | |
var newStartTime = $(startTimeLast).clone(false, false); | |
newStartTime.removeClass('hide clone'); | |
newStartTime.find('.start_time_picker').attr('required', 'required'); | |
parentElLeft.append(newStartTime); | |
newStartTime.find('.start_time_picker').removeClass('ui-timepicker-input'); | |
newStartTime.find('.start_time_picker').timepicker(); | |
// for end time | |
var endTimeLast = $('.start_end_timings').find('.end_time.clone'); | |
var newEndTime = $(endTimeLast).clone(false, false); | |
$(newEndTime).removeClass('hide clone'); | |
var parentElRight = $('.start_end_timings').find('.date_times_right'); | |
parentElRight.append(newEndTime); | |
newEndTime.find('.end_time_picker').removeClass('ui-timepicker-input'); | |
newEndTime.find('.end_time_picker').timepicker(); | |
} | |
var startnextdate = start_date; | |
var startupdatedate; | |
var startInc = 0; | |
$('.date_times_left').find('.start_time').each(function (thisindex, element) { | |
startupdatedate = moment(startnextdate).add(startInc, 'days'); | |
$(element).find('label').html("Start Time for " + startupdatedate.format( | |
"MM/DD/YYYY")); | |
startnextdate = startupdatedate; | |
startInc = 1; | |
}); | |
var endnextdate = start_date; | |
var endupdatedate; | |
var endInc = 0; | |
$('.date_times_right').find('.end_time').each(function (thisindex, element) { | |
endupdatedate = moment(endnextdate).add(endInc, 'days'); | |
$(element).find('label').html("End Time for " + endupdatedate.format( | |
"MM/DD/YYYY")); | |
endnextdate = endupdatedate; | |
endInc = 1; | |
}); | |
$('#sale').data('formValidation').resetForm(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment