it31
asked on
Urgent: Javascript PMT Function()
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
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
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.
Check this link ..
http://www.geocities.com/WallStreet/7437/finance.htm
http://www.geocities.com/WallStreet/7437/finance.htm
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>(va lue.indexO f(".")+dpl aces))){
three=value.substring(valu e.indexOf( ".")+dplac es+1,value .indexOf(" .")+dplace s+2)
one=value.substring(0,valu e.indexOf( ".")+dplac es)
two=value.substring(value. indexOf(". ")+dplaces ,value.ind exOf(".")+ dplaces+1)
if(parseInt(three)>=5){val ue=one+(pa rseInt(two )+1);value =parseFloa t(value)}
else{value=one+two;value=p arseFloat( value)}
}
return value;
}
</script>
<body onLoad="Pmt(5.75,300,-2000 00);">
<script>
function Pmt(r,np,pv,fv) {
r = r/1200
if (!fv) fv = 0;
pmt=-(r * (fv+Math.pow((1+r),np)*pv)
finalPmt=roundOff(pmt,2);
alert(finalPmt);
}
function roundOff(value, dplaces){
value=value.toString()
if((value.indexOf(".")!=-1
three=value.substring(valu
one=value.substring(0,valu
two=value.substring(value.
if(parseInt(three)>=5){val
else{value=one+two;value=p
}
return value;
}
</script>
<body onLoad="Pmt(5.75,300,-2000
If your needing it to parse forms or something for a form based calculator, let me know.
ASKER
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.
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.arachnoid.com/lutusp/finance_old.html
http://www.mcfedries.com/CreatingAWebPage/mortgage.htm