I have the below code
and both EndMonth and EndYear are not being nice, coming out as undefined and NaN. I can guess that its somewhere in the code that does the calculation as below
Anyone wanna point out where I made my mistake?
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...
Code:
function calcPromissory()
{
var tmpStart = document.getElementById('case_promissory_start').value;
var tmpTerm = document.getElementById('CASE.PROMISSORY_TERM').value;
var tmpAmt = document.getElementById('CASE.PROMISSORY_AMT').value;
var tmpEDate = document.getElementById('row_promissory_end_date');
if ( isNaN(tmpTerm) || isNaN(tmpAmt) || tmpTerm == 0 || tmpAmt == 0 ) {return;}
if ( tmpStart == ''){return};
if (!CheckFieldDate("case_promissory_start", tmpStart)){ return; }
var arrDt = tmpStart.split("/");
if (arrDt.len < 3){ alert("Start Date is not a valid date"); return; }
if (tmpTerm > 11){
var addYears = Math.floor(tmpTerm/12);
var addMonths = tmpTerm % 12;
}
var EndYear = Math.abs(arrDt[2]);
EndYear = EndYear + addYears;
var EndMonth = Math.abs(arrDt[0]);
EndMonth = EndMonth + addMonths;
alert(EndMonth);
if(EndMonth > 11){
EndYear = EndYear + 1;
EndMonth = EndMonth-11;
}
alert(EndMonth);
var month=new Array(12);
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var dUpdatePayAmount = document.getElementById('row_promissory_payment_amt');
var nAmtVal = Math.round(tmpAmt / tmpTerm * 100)/100 ;
dUpdatePayAmount.innerHTML = '$' + nAmtVal;
tmpEDate.innerHTML = month[EndMonth] + ' / ' + EndYear;
and both EndMonth and EndYear are not being nice, coming out as undefined and NaN. I can guess that its somewhere in the code that does the calculation as below
Code:
var EndYear = Math.abs(arrDt[2]);
EndYear = EndYear + addYears;
var EndMonth = Math.abs(arrDt[0]);
EndMonth = EndMonth + addMonths;
alert(EndMonth);
if(EndMonth > 11){
EndYear = EndYear + 1;
EndMonth = EndMonth-11;
}
Anyone wanna point out where I made my mistake?
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...