JS help
JS help
Out of context: Reply #10
- Started
- Last post
- 13 Responses
- i_monk0
Yeah I was looking more closely at it and realized the function pv definition didn't end where I thought it did (this format is alien to me), so I'm reworking it:
var N_Shortfall = this.getField("N_Shortfall").val...
var N_Rate = this.getField("N_Rate").value;
var N_Years = this.getField("N_Years").value;
function pv(rate, years, short, fv, pd)
{
rate = N_Rate;
years = N_Years;
short = N_Shortfall;
fv = 0;
pd = 1;
if (rate ==0)
{
pv_value = -(fv + (pd * short));
}
else
{
x = Math.pow(1 + rate, -short);
y = Math.pow(1 + rate, short);
pv_value = - (x * (fv * rate - pd + y * pd )) / rate;
}
return (pv_value);
}
this.getField("N_Amount").value = pv();This is at least producing a number where I expect it to be, and one that's different from the "Yes" number.