I've been researching various topics and so far, I haven't come across one that addresses my specific issue.
Here's the task at hand:
1) Extract a bill date in the mm/dd/yy format, which is often not today's date.
2) Add a dynamic number of days to this date using the terms saved in the dueTime array below. For now, I've limited it to 30 days.
3) Calculate the due date of the bill based on the original bill date and the payment terms, then return it in the mm/dd/yy format.
I've attempted a solution, where the input into new Date appears correct, but the output never matches my expectations.
Thank you for any assistance you can provide.
<html>
<head>
<script>
function calculateDueTime(){
var billDate = document.getElementById('billDateId').value;
var key = document.getElementById('termsId').value;
var dueTime = new Array();
dueTime[1] = 30;
var billDateSplit = billDate.split('/');
var newDate = new Date( parseInt( billDateSplit[2] ) + '/' + parseInt( billDateSplit[0] ) + '/' + ( parseInt( billDateSplit[1] ) + parseInt( dueTime[key] ) ) );
document.getElementById('dueDateId').value = newDate.toString();
}
</script>
</head>
<body>
<input name="billDate" id="billDateId" value="5/1/11" />
Enter date in mm/dd/yy or m/d/yy format
<select name="terms" id="termsId" onchange="calculateDueTime()">
<option value="1">Net 30</option>
</select>
<input name="dueDate" id="dueDateId" />
</body>
</html>