Skip to main content
cindyc6124644
Participant
December 8, 2017
Question

Create a java script that will calculate based on a true value in a checkbox

  • December 8, 2017
  • 1 reply
  • 510 views

I have a form where my end user checks boxes next to a list of items wherby selecting each item they would like to include as extras in their new home. Each Item has a different price and some may have more than 1 quantity. At last there is an Amount column. At the bottom, the individual amounts are calculated as a Total of Extras to add to the Homebuyers Purchase. It is currently set up in an excel spreadsheet and is formulated to calculate the amount (Price X Quanity =Amount) based on the true value of the checkbox. And then of course to add all of the amounts to return a Total.

Example:

Item               Price                  Quantity                  Checkbox                          Amount

Item               Price                  Quantity                  Checkbox                          Amount

Item               Price                  Quantity                  Checkbox                          Amount

                                                                                                                            Total

We would like to put all of these forms (Different forms for each individual Builder's model homes with unique items/prices/square footage) into PDF documents so that our builders can just go to the website and interact with the forms.

I am new to all of this so I would be very greatful if someone could please offer me some assistance in how to program the Java Script each field.

Thanks in Advance!

This topic has been closed for replies.

1 reply

Inspiring
December 8, 2017
cindyc6124644
Participant
December 8, 2017

Thank You!

So, after reading the instructions...

I went to the Java Script Editor for the Amount1 Field and entered the following script:

Var Amount1 = this.getField ("Price1").value;

if ( Check Box2.rawValue==true )

Amount1.value = Price1;

I got:

SyntaxError:missing ) after condition 2: at line 3

I am pretty green at this Java Scripting. Please tell me what this means and

what I should correct to get it to work properly.

Thanks!

Thom Parker
Community Expert
Community Expert
December 9, 2017

So is this a LiveCycle form? Are you editing it in LiveCycle Designer? or is this an Acrobat form?  and you are editing it in Acrobat?

And what kind of script did you enter? Calculation Script, format script, etc.?

The script you've provided mixes different form technologies and does not have the syntax error that is shown. Is there more to the script?

Have you considered hiring a professional to fix up your form?  You would save a lot of time and money?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often