I'm using jquery datepicker to calculate price according to selected date. Now it's set 125 for one month. I want to make a discount 5% if customer chooses 3 months period and 10% if customers chooses 4+ months.
How to do it?
http://jsfiddle.net/5BbGS/502/
function showDays() {
var start = $('#arr_date').datepicker('getDate');
var end = $('#dep_date').datepicker('getDate');
if (!start || !end) return;
var days = (end - start) / 1000 / 60 / 60 / 24;
var dayss = days*4.166666666666667;
dayss = dayss.toFixed(0);
$('#num_nights').val(dayss);
}
$("#arr_date").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: showDays,
onClose: function( selectedDate ) {
var dParts = selectedDate.split('-');
var in30Days = new Date(dParts[2] + '/' +
dParts[1] + '/' +
(+dParts[0] + 30)
);
$( "#dep_date" ).datepicker( "option", "minDate", in30Days );
}
});
$("#dep_date").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: showDays,
});
Thank you guys!