How to calculate End date after adding some days to startdate

sometimes we need to calculate a date after adding some duration to a date just for example doctor pescribe a medicine for some days so end date will be today + some duration.

we have to do it in clientside in javscript function write these

//USES MASTER PAGE
  function CalculateEndDate()
{
  var startTime =  document.getElementById('<%=txtstartDate.ClientID%>').value;//START DATE

            var objvalDur = document.getElementById('<%=ddlDuration.ClientID%>').value;//duration

//calculate end date

   var d = new Date(startTime);

                    d.setDate(d.getDate()+durTime);

                    var exactDate = (d.getMonth()+1)+"/"+d.getDate()+"/"+d.getYear();

                    document.getElementById('<%=txtendDate.ClientID%>').value=exactDate;

}

Comments