# Present value of a single sum calculator

Posted in: Capital budgeting techniques (calculators)

Future value:

Number of periods:

Interest rate per period:

Skip to content
# Present value of a single sum calculator

function myFunction()
{
var x;
var y;
var z;
var errors;
x=fv.value;
y=nop.value;
z=ir.value;
x=x.replace(/[^0-9.]/g, '');
y=y.replace(/[^0-9.]/g, '');
z=z.replace(/[^0-9.]/g, '');
x=parseFloat(x);
y=parseFloat(y);
z=parseFloat(z);
presentvalue=x/Math.pow(1+z/100, y)
if (x=="0")
{
document.getElementById("error1").innerHTML="This field cannot be zero.";
errors=true;
}
else if (fv.value=="")
{
document.getElementById("error1").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error1").innerHTML="";
}
if (y=="0")
{
document.getElementById("error2").innerHTML="This field cannot be zero.";
errors=true;
}
else if (nop.value=="")
{
document.getElementById("error2").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error2").innerHTML="";
}
if (z=="0")
{
document.getElementById("error3").innerHTML="This field cannot be zero.";
errors=true;
}
else if (ir.value=="")
{
document.getElementById("error3").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error3").innerHTML="";
}
if (errors==true)
{
document.getElementById("prevalue").innerHTML="";
return false;
errors=false;
}
if (isNaN(presentvalue))
{
presentvalue = "0";
}
if (presentvalue == Number.POSITIVE_INFINITY || presentvalue == Number.NEGATIVE_INFINITY)
{
presentvalue="0";
}
presentvalue = parseFloat(presentvalue);
presentvalue = Math.round(presentvalue*100)/100;
presentvalue = presentvalue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
document.getElementById("loading").style.visibility = "visible";
setTimeout(function(){Timer1()},1200);
}
function Timer1() {
document.getElementById("loading").style.visibility = "hidden";
document.getElementById("prevalue").innerHTML="Present value: "+"$"+presentvalue;
}
function reset()
{
fv.value="";
nop.value="";
ir.value="";
document.getElementById("prevalue").innerHTML="";
document.getElementById("error1").innerHTML="";
document.getElementById("error2").innerHTML="";
document.getElementById("error3").innerHTML="";
}

Menu

Find

Posted in: Capital budgeting techniques (calculators)

Future value:

Number of periods:

Interest rate per period:

Copyright 2012 - 2021. Accounting For Management

## Leave a comment