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

Getting javascript to work properly

Community Beginner ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Hello, I am somewhat familiar with javascript but have no idea on how to get it to work properly on an adobe form that I am using. Right now I have a form with dropdowns with selections of "Yes", "No", "N/A" , and I want calculate the total number of each and print the result to a "totals" box at the bottom of the page.  I have tried to put the below code into the "Yes" totals box but I dont have any idea on how to implement in addition to not knowing If I wrote it correctly. Here is the code I wrote for calculating "Yes":

var a = 0;

for ( var i=1; i<= 32; i++){
if(this.getField("AnalysisAccess"+i).valueAsString == "Yes")a++;
};

console.printLn(a.value);

Views

581

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

correct answers 1 Correct answer

Community Expert , Jun 03, 2021 Jun 03, 2021

If you use script in "Total" field change last line

from: console.printLn(a.value);

 

to: event.value = a;

Votes

Translate

Translate
Community Expert ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

[Assuming you're using Acrobat Pro DC, moderator moved this from Using the Community (forums) to Acrobat.]

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

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 ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

If you use script in "Total" field change last line

from: console.printLn(a.value);

 

to: event.value = a;

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 ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Thank you, does it need to be wrapped in a function?

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 ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

LATEST

No.

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 ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Use

console.println(a);

not

console.printLn(a.value);

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