Javascript: Adding days to any date
<p>I've read through a number of topics now and have not found one quite on point.</p>

<p>Here's what I'm trying to do:<br>
1) Parse a bill date that is provided in the format mm/dd/yy and is frequently not today<br>
2) Add a variable number of days to the date. The terms are saved in the dueTime array below.  I limited it to 30 days here.<br>
3) Based on the bill date + the payment terms, calculate the date that the bill is due and return that in the mm/dd/yy format.  </p>

<p>Here's what I've tried.  The information I pass into new Date is what I expect, but the output from new date is never what I expect.</p>

<p>Thanks for your help.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
function calculateDueTime(){
    var billDate = document.getElementById('billDateId').value;
    var key = document.getElementById('termsId').value;
    var dueTime = new Array();
    dueTime[1] = 30;
    var billDate = billDate.split('/');
    var newDate = new Date( parseInt( billDate[2] ) + '/' + parseInt( billDate[0] ) + '/' + ( parseInt( billDate[1] ) + parseInt( dueTime[key] ) ) ); 
    document.getElementById('dueDateId').value = newDate.toString();
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;input name="billDate" id="billDateId" value="5/1/11" /&gt; 
Or any value in mm/dd/yy or m/d/yy format
&lt;select name="terms" id="termsId" onchange="calculateDueTime()"&gt;
   &lt;option value="1"&gt;Net 30&lt;/option&gt;
&lt;/select&gt;
&lt;input name="dueDate" id="dueDateId" /&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
