Adobe Acrobat script to calculate prorated rent based upon values in text boxes not working?

New Here ,
Mar 29, 2020

Copy link to clipboard

Copied

I'm trying to create a script to calculate the prorated rent based upon the move-in date on a PDF form and the script keeps coming back with odd prorated amounts...the MoveInDay = 12, DaysRentIsDue = 19 and RentRateDaily = 76.37 but the event.value it comes back with in my RentProratedDue field is 2291.10 which makes no sense to me based upon the simple script below; all I'm asking it to do is basically do the following math: 76.37 * 19 = 1451.03, right?  Please let me know what I'm doing wrong...thx! 🙂

 

{
if (this.getField("MoveInDay").value > 1)
event.value = this.getField("RentRateDaily").value * this.getField("DaysRentIsDue").value;
else
event.value = this.getField("RentRate").value;
}

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here is a tutorial on the Console:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

Acrobat X has a slightly different UI, but Control-J still works just fine. 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

55

Likes

Translate

Translate

Report

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

Adobe Acrobat script to calculate prorated rent based upon values in text boxes not working?

New Here ,
Mar 29, 2020

Copy link to clipboard

Copied

I'm trying to create a script to calculate the prorated rent based upon the move-in date on a PDF form and the script keeps coming back with odd prorated amounts...the MoveInDay = 12, DaysRentIsDue = 19 and RentRateDaily = 76.37 but the event.value it comes back with in my RentProratedDue field is 2291.10 which makes no sense to me based upon the simple script below; all I'm asking it to do is basically do the following math: 76.37 * 19 = 1451.03, right?  Please let me know what I'm doing wrong...thx! 🙂

 

{
if (this.getField("MoveInDay").value > 1)
event.value = this.getField("RentRateDaily").value * this.getField("DaysRentIsDue").value;
else
event.value = this.getField("RentRate").value;
}

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here is a tutorial on the Console:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

Acrobat X has a slightly different UI, but Control-J still works just fine. 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

56

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 29, 2020 0
Adobe Community Professional ,
Mar 29, 2020

Copy link to clipboard

Copied

Is there anything else (other scripts) that could be affecting this field?

 

What do you get when you run this code in the console?

 this.getField("RentRateDaily").value * this.getField("DaysRentIsDue").value;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 29, 2020 0
New Here ,
Mar 30, 2020

Copy link to clipboard

Copied

Hi Thom!  Wow...I didn't realize that a Javascript Console existed!  I have Acrobat X...do you know where in Acrobat X I can find the Console?  Yes once I find that I'm confident I'll be able to figure out why the script isn't calculating correctly! 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 30, 2020 0
Adobe Community Professional ,
Mar 31, 2020

Copy link to clipboard

Copied

Here is a tutorial on the Console:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

Acrobat X has a slightly different UI, but Control-J still works just fine. 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 31, 2020 1