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

Need help with auto calculation update using javascript

Community Beginner ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Hello,

 

I'm pretty fresh with javascript, I have written the following code that works as the following, the first page of this pdf has a lot of information that the customer will fill out, community name, price of home, sales tax and so forth. Once this information is filled out they will click a button that will auto populate this information into the next page, most of it is just copying information down. I would like to however be able to have it auto run the script and or once you click the button once it keeps running the script maybe to keep updating the fields because if they were to change the prices or other price information I would like for it to update the totals and so forth, this way if someone were to go in and edit one of the price fields it would then re-calculate everything on the form automaticaly instead of them having to re-click the calculate button again? Is this possible, does this make sense what I'm trying to do?

 

Here is my very basic code below, not amazing I know, but its working to copy information from one field name to another and still giving them the ability to update any of it if they need to.

 

//Main Information New PDF Information
this.getField("Make2").value = this.getField("Make").value;
this.getField("SerialNumber2").value = this.getField("SerialNumber").value;
this.getField("Year2").value = this.getField("Year").value;
this.getField("Model2").value = this.getField("Model").value;
this.getField("Width2").value = this.getField("Width").value;
this.getField("Length2").value = this.getField("Length").value;
this.getField("PriceofHome2").value = this.getField("TotalMaximumPackagePrice").value;
this.getField("SalesTax2").value = this.getField("SalesTax").value;
this.getField("DownPaymentPercentage2").value = this.getField("CashDownPayment").value;
var priceofHome = this.getField("PriceofHome2").value;
var salesTax = this.getField("SalesTax2").value;
this.getField("LoanAmountTotal2").value = priceofHome + salesTax;
this.getField("InstallationandSetup2").value = this.getField("InstallationandSetup").value;

//Accessories Included in Sales Price of the Home
this.getField("InstallationandSetup2").value = this.getField("InstallationandSetup").value;
this.getField("ImprovementsFooters2").value = this.getField("ImprovementsFooters").value;
this.getField("AirConditioner2").value = this.getField("AirConditioner").value;
this.getField("DecksStairs2").value = this.getField("DecksStairs").value;
this.getField("Skirting2").value = this.getField("Skirting").value;
this.getField("HookupsPermits2").value = this.getField("HookupsPermits").value;
var otherPrice1 = this.getField("Other1Price").value;
var otherPrice2 = this.getField("Other2Price").value;
this.getField("AccessoriesOther").value = otherPrice1 + otherPrice2;

//Total for the Other Fees Section
var loanamountTotal = this.getField("LoanAmountTotal2").value;
var tradeinTotal = this.getField("TotalDownPayment").value;
var otherfeesHidden = this.getField("OtherFeesTotalHidden").value;
this.getField("OtherFeesTotal").value = ((loanamountTotal - tradeinTotal) + otherfeesHidden);

//Final Box of Fill in Information
this.getField("NameofCommunity2").value = this.getField("NameofCommunity").value;

 

TOPICS
Acrobat SDK and JavaScript

Views

466

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
community guidelines
Community Expert ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

You can use calculation scripts at the fields "Make2", "SerialNumber2", and so on.

Votes

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
community guidelines
Community Beginner ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

When you say the calculation scripts, what do you mean in the fields "Make2", "SeriealNumber2"? I don't think I am following. Sorry!

Votes

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
community guidelines
Community Expert ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

At the calculation of the fields. 

Votes

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
community guidelines
Community Beginner ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

What code is needed for this to work? Is it the following or something else?

this.calculateNow();

 

Votes

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
community guidelines
Community Expert ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

E.g. In the simplified field notation of field "Make2" enter: Make 

Votes

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
community guidelines
Enthusiast ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Button can't auto run script, you need to put code in text field to auto update when values changes, or click button every time user change something.

Votes

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
community guidelines
Community Beginner ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Do you know if I would need to add a code like the following to the text field? Or would it be something else? Also if I have the script in a button to auto fill this all down to the next page, can I just add the code to a certain field it will still auto update?

Votes

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
community guidelines
Community Expert ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

LATEST

That is not the best method.

 

What Asim and Berndt were saying is to run the script as a custom calculation script on each of the totaling fields.

Votes

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
community guidelines