# Urgent: Javascript PMT Function()

on
In the visual basic and excel have a function call pmt(), it can calculator payment.

This is VB sample command:
lvTotInterest = Format(Pmt(0.0575 / 12, 300, 200000 * -1), "#########.00")

The answer will come out: 1258.21

Will increase the points to 300 points by later.

Thanks
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
P.S. -- I don't think that there is a JavaScript solution without having to create a function (which the sites above might help with)

Commented:
if I had the calculations, I could throw it together pretty quickly, but I'm not up for searching out the calculations of what you need. I presume 1258.21 is the amt you pay each time.... where the first number (.0575/12) is the monthly interest and 200000 is the total value taken out on loan while 300 is the number of payments. If this is correct and you can link me to a formula or provide me with the formula, I will gladly throw something together.

Commented:
I'm not too sure where you want to go with it, but try this:

<script>
function Pmt(r,np,pv,fv) {
r = r/1200
if (!fv) fv = 0;
pmt=-(r * (fv+Math.pow((1+r),np)*pv)/(-1+Math.pow((1+r),np)));
finalPmt=roundOff(pmt,2);
}

function roundOff(value, dplaces){
value=value.toString()

if((value.indexOf(".")!=-1)&&(value.length>(value.indexOf(".")+dplaces))){
three=value.substring(value.indexOf(".")+dplaces+1,value.indexOf(".")+dplaces+2)
one=value.substring(0,value.indexOf(".")+dplaces)
two=value.substring(value.indexOf(".")+dplaces,value.indexOf(".")+dplaces+1)
if(parseInt(three)>=5){value=one+(parseInt(two)+1);value=parseFloat(value)}
else{value=one+two;value=parseFloat(value)}
}
return value;
}

</script>

Commented:
If your needing it to parse forms or something for a form based calculator, let me know.

Commented:
kenny9336,

Thank you for the reply, it look like can work.

And are you have the function for PPmt in javascript?

I will increase the points after EE Support Team delete my other Unlock Question, thanks.

Commented:
i gotta look up the formula for it and write the code, but I can do it.

Commented:
hmm.. i'm having a slight difficulty finding this formula.. anyone got a economics book?
Commented:
well, i've found that PPmt = Pmt - IPmt... now if i could find a formula for IPmt... any one on this?

Do more with