I have a url parameter called commencing date in the format of dd-mm-yyyy. I have input fields in my html field and I need to set dates to those input fields. I need to dates to be set like this. If the commencing date(url parameter string) is 01-01-2014 , the first input field should have the date of 15-02-2015. That means 1 month and 2 weeks later. Then the next input field should have the date 1 month and 2 weeks after the 15-02-2014. This should happen say 10 times. I am doing it using a for loop.I have assigned jquery datepicker for my input fields.
var initialDate = "01-01-2014";
var x;
for(x=1; x<= 10;x++){
var dateArray = initialDate.split("-");
var dateObj = new Date(dateArray[2],dateArray[1],dateArray[0]);
dateObj.setMonth(dateObj.getMonth()+1);
dateObj.setDate(dateObj.getDate()+14);
// Assign the new date value to input field.
$("#dateOf_installment_"+x).val(dateObj.getDate()+"-"+dateObj.getMonth()+"-"+dateObj.getFullYear());
}
But this does not give me the required values. How to solve this problem, Thanks all!