Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

286

Likes

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

Adobe Community Professional , 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;

Likes

Translate

Translate
Adobe Community Professional ,
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, Adobe Product User & Community Professional
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Likes

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
Adobe Community Professional ,
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;

Likes

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?

Likes

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

Copy link to clipboard

Copied

LATEST

No.

Likes

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

Copy link to clipboard

Copied

Use

console.println(a);

not

console.printLn(a.value);

Likes

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