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

Create Scorecard using multiple if / else if / else if statements, and add points

New Here ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

I am attempting to create a fill-in PDF form that is a scorecard.  Points values are assigned based on what the user selects from a drop down list.  I have the individual points working, however, there are a lot of Syntax Errors.  Also, I cannot figure out how to add all the different values together. I have tried simply making the total a calculated field that is simply the sum of the fields picked from the list, but it just shows as zero.  I have confirmed the calculation order and the total is listed last, but still no success. 

Here are a few examples and the javascript used: 

I have ResidenceStatus as a drop down field with the choices below.  This is the javascript from the ResidenceStatusScore field:

var ResidenceStatus = this.getField("ResidenceStatus").value;

if (ResidenceStatus=="Owns/Buying") event.value = "55";

else if (ResidenceStatus=="Rents") event.value = "40";

else if (ResidenceStatus=="Other") event.value = "30";

else if (ResidenceStatus==" ") event.value = "0"

I also have an Account field as a drop down with the choices below.  Here is the javascript for the AccountScore:

var Account = this.getField("Account").value;

if (Account=="Checking AND Savings") event.value = "44";

else if (Account=="Checking Only") event.value = "35";

else if (Account=="Savings Only") event.value = "30";

else if (Account=="None") event.value = "25";

else if (Account==" ") event.value = "0"

The individual score fields work as expected and change appropriately if the user changes their selection from the drop down, however, I need a total score that adds these individual scores together.

I have turned on Debugger, but here are all the errors I am getting:

SyntaxError: syntax error

1:

SyntaxError: missing : after property id

5:

SyntaxError: missing : after property id

4:

SyntaxError: syntax error

4:

SyntaxError: syntax error

1:Console:Exec

undefined

SyntaxError: syntax error

1:Console:Exec

undefined

SyntaxError: syntax error

5:

SyntaxError: syntax error

5:

SyntaxError: syntax error

5:

TypeError: f is null

1051:byteCodeTool

TypeError: f is null

1051:byteCodeTool

TypeError: f is null

1051:byteCodeTool

TypeError: f is null

1051:byteCodeTool

Also, I can't get the fields to sum for the total. 

Any help would be most appreciated!! 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

172

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 ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

LATEST

Good on you for looking at the console window!!

However, without actually seeing the code the error messages don't make any sense. But it sounds like you need a lot of help.

Please re-post a single issue, showing the code related to that single issue.

Alternatively, you could seek to learn more about scripting here:

Free Video Content & Full Listing of Available Videos

Or you could hire a trainer/consultant to walk you through all the fixes. (like me, message me if you are interested)

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

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