Question : Adding days to an input date value.

Hi all,
I need your help with this!
I do have a date in this format (30-Jul-2010) and it is shown in a text box along with a calendar icon so the user can select the date by clicking on the icon.

The problem that I’m facing is that I need to add number of days to that date and display them in textboxes.
Ex:
Date1 = selected Date + 1 day
Date2 = selected Date + 3 days
Date3 = selected Date + 4 days
Date4 = selected Date + 5 days

I tried the following in javascript but its not working:

TDate=”30-Jul-2010”;
var newTDate = new Date(formatDate(TDate));
document.getElementById("Date1").value=newTDate.getDate()+1;
document.getElementById("Date2").value=newTDate.getDate()+3;
document.getElementById("Date3").value=newTDate.getDate()+4;
document.getElementById("Date4".value=newTDate.getDate()+5;

function formatDate(sDate)
{
      var dateSplit=sDate.split("-");
      newDate=dateSplit[1] + " " + dateSplit[0] + "," + dateSplit[2];
      return newDate
}

Appreciate your help…..thanks in advance.

Answer : Adding days to an input date value.

Random Solutions  
 
programming4us programming4us