Highlighted

COUNTING A TEXT FROM A DROPDOWN LIST IN DIFFERENT FIELDS IN ADOBE ACROBAT PRO.

New Here ,
Nov 20, 2020

Copy link to clipboard

Copied

HI, I WAS WONDERING IF YOU CAN HELP ME WITH THIS ISSUE...

 

I HAVE A FORM THAT HAVE 15 FIELDS

EACH FIELD HAVE A DROPDOWN LIST WITH 3 OPTIONS TO CHOOSE:  LIB., REC., AND SCAN

AT THE BOTTON OF THE PAGE ARE 3 FIELDS: LIB., REC, AND SCAN TOO. NOW...

I WANT TO PUT IN THOSE 3 FIELDS FROM THE BOTTOM OF THE PAGE, THE COUNTED AMOUNT OF

LIB. FROM THE DROPDOWN LIST, THE REC., AND THE SCAN FROM ALL THOSE 15 FIELDS.

[Email address removed by moderator]

Thank You!

NM PULL OUT LIST - DIAGRAM.PNG

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

48

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

COUNTING A TEXT FROM A DROPDOWN LIST IN DIFFERENT FIELDS IN ADOBE ACROBAT PRO.

New Here ,
Nov 20, 2020

Copy link to clipboard

Copied

HI, I WAS WONDERING IF YOU CAN HELP ME WITH THIS ISSUE...

 

I HAVE A FORM THAT HAVE 15 FIELDS

EACH FIELD HAVE A DROPDOWN LIST WITH 3 OPTIONS TO CHOOSE:  LIB., REC., AND SCAN

AT THE BOTTON OF THE PAGE ARE 3 FIELDS: LIB., REC, AND SCAN TOO. NOW...

I WANT TO PUT IN THOSE 3 FIELDS FROM THE BOTTOM OF THE PAGE, THE COUNTED AMOUNT OF

LIB. FROM THE DROPDOWN LIST, THE REC., AND THE SCAN FROM ALL THOSE 15 FIELDS.

[Email address removed by moderator]

Thank You!

NM PULL OUT LIST - DIAGRAM.PNG

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

49

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
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

In the "LIBRARY", RECORD CENTER", and "SCANS" fields use a custom calulation script to count for those values.

 

Also make sure that in the dropdown field options tab, the properties are set to commit slecet value immediately.

 

// USE THIS IN THE LIBRARY FIELD

var total = 0; 
for (var i=0; i<15; i++) { 
var v = "LIB.";  
if (this.getField("myDropdown"+i).valueAsString==v) total++;  
event.value = total;
}


// USE THIS IN THE RECORD CENTER FIELD

var total = 0; 
for (var i=0; i<15; i++) { 
var v = "REC.";  
if (this.getField("myDropdown"+i).valueAsString==v) total++;  
event.value = total;
}


// USE THIS IN THE SCAN FIELD

var total = 0; 
for (var i=0; i<15; i++) { 
var v = "SCAN";  
if (this.getField("myDropdown"+i).valueAsString==v) total++;  
event.value = total;
}

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
Reply
Loading...
Nov 20, 2020 0
Most Valuable Participant ,
Nov 20, 2020

Copy link to clipboard

Copied

Move the line

event.value = total;

outside of the for-loop bracket.

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
Reply
Loading...
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

Thank you as usual.

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
Reply
Loading...
Nov 20, 2020 0
Most Valuable Participant ,
Nov 20, 2020

Copy link to clipboard

Copied

Also, change:

i<15

to:

i<=15

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
Reply
Loading...
Nov 20, 2020 0
Most Valuable Participant ,
Nov 20, 2020

Copy link to clipboard

Copied

And i=0 to i=1...

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
Reply
Loading...
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

About that, I had to change to 0 because if I did it with a 1 in the equation if wouldn't count all the fields. The totals were coming up short by 1... which is weird because this is the exact same script that you help me with the first time I posted an inquiry when I joined the forums.

 

So if I had 4 fields, only three would be the total if used 1 in the equation. But I think that was because of not moving the event.value outside of the brackets like you pointed out.

 

My Acrobat has been acting out a little bit after the last November update. I am also not getting the correct Mouse-up events to work as expected when using radio buttons. Maybe is because of the same reasons in my script not having the event.value portion  outsie of the brackets as you suggest.

 

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
Reply
Loading...
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

I just confrmed, it doesn't matter if event.value is outside of the brackets, if I switch from 0 to 1 in the loop it calculates fine but misses one count.

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
Reply
Loading...
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

And adding this   

i<=15

 

instead of i<15 breaks my script and it doesn't calculate... there's something wrong with my Acrobat.

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
Reply
Loading...
Nov 20, 2020 0
Adobe Community Professional ,
Nov 20, 2020

Copy link to clipboard

Copied

It's all about how the fields are named. The poster states the fields are 1i thru 15i, hence the limits on the for loop.  

 

In this case, moving the event.value line to the outside of the loop is a matter of style. In fact, if you're going to set it on every iteration, why use the total variable at all (it's redundant), just use event.value for the total calculation.  In a more complicated script, this could be a bug. So its always a good idea to follow consisent coding practices.  

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
Reply
Loading...
Nov 20, 2020 1