Need help with auto calculation update using javascript
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;
