Urgent: Javascript PMT Function()

it31
it31 used Ask the Experts™
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

So how about javascript?

Will increase the points to 300 points by later.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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)
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.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

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);
alert(finalPmt);
}

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>

<body onLoad="Pmt(5.75,300,-200000);">
If your needing it to parse forms or something for a form based calculator, let me know.

Author

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.
i gotta look up the formula for it and write the code, but I can do it.
hmm.. i'm having a slight difficulty finding this formula.. anyone got a economics book?
well, i've found that PPmt = Pmt - IPmt... now if i could find a formula for IPmt... any one on this?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial