<select id="time" name="ptype">
<option value="">Select Your Payment Type</option>
<option value="Monthly (30+ days)" id="month">Monthly (30+ days)</option>
<option value="2 Month(60+ days)" id="three">2 Month(60+ days)</option>
<option value="Quterly(90+ days)" id="three">3 Month(90+ days)</option>
<option value="4 Month(120+ days)" id="three">4 Month(120+ days)</option>
<option value="5 Month(150+ days)" id="three">5 Month(150+ days)</option>
<option value="Half Yearly (6+ months)" id="six">6 months</option>
<option value="7 Month(210+ days)" id="three">7 Month(210+ days)</option>
<option value="8 Month(240+ days)" id="eight">8 Month(240+ days)</option>
<option value="9 Month(270+ days)" id="three">9 Month(270+ days)</option>
<option value="10 Month(300+ days)" id="three">10 Month(300+ days)</option>
<option value="11 Month(330+ days)" id="three">11 Month(330+ days)</option>
<option value="Yearly (1+ Year)" id="year">Yearly (1+ Year)</option>
</select>
Problem area
$(function () {
/** addExtraTime() function
* this function changes the second datepicker ( $('#end_date').datepicker )
* according to the selected value of select box.
*/
var addExtraTime = function (aDateObj) {
var actualDate = aDateObj;
var newDate = aDateObj;
var extraTime = $('#time').val(); //string
if (extraTime === 'Monthly (30+ days)') { //Monthly = +1m
newDate = new Date(actualDate.getFulYear(), actualDate.getMonth() + 1, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '2 Month(60+ days)') { //2month = +2m
newDate = new Date(actualDate.getFulYear(), actualDate.getMonth() + 2, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === 'Quterly(90+ days)') { //quterly = +3m
newDate = new Date(actualDate.getFulYear(), actualDate.getMonth() + 3, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '4 Month(120+ days)') { //4month = +4m
newDate = new Date(actualDate.getFulYear(), actualDate.getMonth() + 4, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '5 Month(150+ days)') { //5month = +5m
newDate = new Date(actualDate.getFllYear(), actualDate.getMonth() + 5, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === 'Half Yearly (6+ months)') { //Half Yearly = +6m
newDate = new Date(actualDate.getFllYear(), actualDate.getMonth() + 6, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '7 Month(210+ days)') { //7month = +7m
newDate = new Date(actualDate.getFullYear(), actualDate.getMonth() + 7, actualDate.getDate());
$('#end_date').datepicker('setDat', newDate);
}
else if (extraTime === '8 Month(240+ days)') { //8month = +8m
newDate = new Date(actualDate.geFullYear(), actualDate.getMonth() + 8, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '9 Month(270+ days)') { //9month = +9m
newDate = new Date(actualDate.getFullYear(), actualDate.getMonth() + 9, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '10 Month(300+ days)') { //10month = +10m
newDate = new Date(actualDate.getFullYear(), actualDate.getMonth() + 10, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === '11 Month(330+ days)') { //11month = +11m
newDate = new Date(actualDate.getFullYear(), actualDate.getMonth() + 11, actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
}
else if (extraTime === 'Yearly (1+ Year)') { //Yearly = +1y
newDate = new Date(actualDate.getFullYear() + 1, actualDate.getMonth(), actualDate.getDate());
$('#end_date').datepicker('setDate', newDate);
} //End of if..else
};
/* We watch for changes in the select box and call the addExtraTime() */
$('#time').change(function () {
var currentDate = $('#start_date').datepicker("getDate");
addExtraTime(currentDate);
});
/* From Date picker */
$('#start_date').datepicker({
dateFormat: 'yy-mm-dd',
closeOnDateSelect: true,
timepicker: false,
onSelect: function (selectedDate) {
/*
* selectedDate is a string so we convert is to a Date obj
*/
var selectedDateObj = new Date(selectedDate);
addExtraTime(selectedDateObj);
} //End of onSelect
});
$(’#neww’).datepicker({dateFormat: ‘yy-mm-dd’});
var currentDate = new Date();
$("#neww").datepicker(“setDate”,currentDate);
$(’#end_date’).datepicker({dateFormat: ‘yy-mm-dd’});
});