Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PV (present value) value for Rate, Nper & PMT

New Here ,
Aug 11, 2018 Aug 11, 2018

I am new to Javascript and trying to create PDF form which will calculate PV (present value) value for based on fields like Rate, Nper & PMT. Please help me regarding this. I think people with good experience about Javascript can solve this.

TOPICS
PDF forms
4.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Aug 13, 2018 Aug 13, 2018

That's happening because you're trying to divide by zero.

Use this instead:

var R = Number(this.getField("Rate").valueAsString);

var N = Number(this.getField("NPER").valueAsString);

var P = Number(this.getField("PMT").valueAsString);

if (R!=0) {

    event.value =P*(1-(Math.pow((1+(R/100)),-N)))/(R/100);

} else event.value = "";

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 11, 2018 Aug 11, 2018

This has been asked before. Have you used the search feature?

Do we need to supply the formula and code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2018 Aug 11, 2018

Hi, I used search but I could not find PV formula which I can use to get the result. Please supply the formula and code and kindly also help me how to put and where to put the code so it executes. I really don't have Javascript knowledge. Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2018 Aug 11, 2018

What I need is that I will fill Rate, Nper, and PMT in the fields and value will display in another field. Please help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

You expect us to do your work for you? If you want help with it provide the formula and we could help you convert it to JS code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

http://Img.png

This is the image which shows what I need. In yellow cell (excel), I wnt this in PDF form and I will enter the data and PDF form which will calculate the data in the other cells. In Column C what is the method required to get the data in column D. Pls help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

This screenshot is useless. Provide the detailed formula, or at the very least describe the way it is done in Excel.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

I am using this formula for pv

R = this.getField("Rate").value;

N = this.getField("NPER").value;

P = this.getField("PMT").value;

event.value =P*(1-(Math.pow((1+(R/100)),-N)))/(R/100);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

It seems like you already have the code that does it...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

The code is working but thing is that until I enter the value in the form , it keeps on showing me alert messages which says "the value entered doesnt match the format of the field. How to remove this alert message?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

That's happening because you're trying to divide by zero.

Use this instead:

var R = Number(this.getField("Rate").valueAsString);

var N = Number(this.getField("NPER").valueAsString);

var P = Number(this.getField("PMT").valueAsString);

if (R!=0) {

    event.value =P*(1-(Math.pow((1+(R/100)),-N)))/(R/100);

} else event.value = "";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

Can I put If...else statement which you showed throughout the fields in the PDF forms?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

Not sure what you mean...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

I mean I have several fields in the PDF form which are same as I sent you in the Excel image. All the fields are showing the same alert message . Example I am sending you

This is for APV field code

if(this.getField("APV")!==0)

{

event.value = getField("NOI").value/ getField("CR").value*100;

}

else

{

event.value=0;

}

I have set the fields code in javascript like this in all the fields using If...else statement. Now I am getting such alert messages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

Your code is not correct. Go back to the sample I provided and study it carefully.

You need to check if the denominator in each calculation is zero.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2018 Aug 13, 2018

Can you please make (correct) this code ?

if (this.getField("APV")!==0)

{

event.value = getField("NOI").value/ getField("CR").value*100;

}

else

{

event.value=0;

}

then I will follow and repeat the same throughout the form.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

You must test the value of the field APV.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2018 Aug 13, 2018

You must test the value of the field, but not APV, as it has nothing to do with this calculation... In this case, replace the first line with:

if (Number(this.getField("CR").valueAsString)!==0)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

thank you it is working. but now there are other problems as the calculations is based on the field values which are scattered in the form so some of the calculation is not happening. I tried setting calculation order also but it also didnt work well.Do you suggest another method for this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2018 Aug 14, 2018

Setting the calculation order should solve the issue. If it didn't there's probably some kind of error. Did you check the JS-Console?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

It didn't, can I share the file with you, please? I have minimum JS knowledge so having difficulty.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2018 Aug 14, 2018

Yes, you can email it to me to try6767 at gmail.com, or upload it to a file-sharing website (Dropbox, Google Drive, Adobe Send & Track, etc.) and then post the link to it here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

Thank you, I have sent you two files. Please see if the problem can be solved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018
LATEST

I emailed you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines