Acrobat Pro DC Textfelder addieren die ein bestimmten Text beinhalten

Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Hallo an alle,

brauche ein "bisschen" Hilfe

Wie kann ich mit Acrobat Pro DC (oder alternative Adobe LiveCycle Designer ES4) Textfelder addieren die ein bestimmten Textinhalt haben?

Bei einer anderen Textfeld reihe möchte ich Textfelder addieren die ein wert oder Text haben, wenn leer dann nicht zählen.

Ich weiß das dies mit Java möglich ist, als Laie weiß ich nur nicht wie

Danke für jede Hilfe im Voraus

Niko

TOPICS
Acrobat SDK and JavaScript, Windows

Views

493

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

Participant , Aug 07, 2019 Aug 07, 2019
It does not add up the fields with content text  var count = 0;      for (var i=10; i<=19; i++) {          if (this.getField(i).valueAsString != "") count++;      }      event.value = count; 

Likes

Translate

Translate
Adobe Community Professional ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Want you build the sum of fields or count the filled fields?

Info: Acrobat uses Javascript, not Java.

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Hi Bernd Alheit,

I want to use Acrobat Pro DC to add text fields that have a specific text content (what ever can be this text).

With another text field row I want to add text fields that have a value or text, if empty then don't count.

Thx

Niko

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

You can use something like this:

var count = 0;

// for fields with specific text:

if (this.getField(" field name ").valueAsString == " specific text ") count++;

// for non-empty fields:

if (this.getField(" field name ").valueAsString != "") 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
community guidelines
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Thank you very much, great that it was so fast and accurate.

Could scream with joy

My last question, where is it inserted?

Text field properties in calculation or validation?

...or better, where and how exactly is this inserted?

Thx

Niko

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

At the calculation of the field where you want display the result.

At the end add the line:

event.value = 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
community guidelines
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Thanks again for your help.

It's really a big help for me.

I'll use it tomorrow, when I'm back in the office.

Since I found this forum, I start to see some light in my Acrobat tunnel.

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

ll be at the office as soon as I can to try it out...I was determined to finish it today.

var count = 0;

if (this.getField(" field name ").valueAsString != "") count++;

event.value = count;

It works, but I don't know how to add all Text boxes (fields) i want.

The script is only for one text box, but wants to add several text boxes together if it is content.

How do I add several text boxes together if they are not empty?

sorry if I get on my nerves and thanks again in advance

Niko

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

If I may add an example.

I want to count Text Box 10 to 19 if Text Box has content, if no content doesn't count then.

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

You can use something like this:

var count = 0;

for (var i=10; i<=19; i++) {

    if (this.getField("Text Box"+i).valueAsString != "") count++;

}

event.value = 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
community guidelines
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

I'm doing something wrong.

I have text fields named "10" to "19", I copied the script, but it doesn't work.

    var count = 0; 

    for (var i=10; i<=19; i++) { 

        if (this.getField("10"+i).valueAsString != "") count++; 

    } 

    event.value = count; 

where do I make the mistake?

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Change:

getField("10"+i)

To:

getField(i)

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

It does not add up the fields with content text

  var count = 0; 

    for (var i=10; i<=19; i++) { 

        if (this.getField(i).valueAsString != "") count++; 

    } 

    event.value = 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
community guidelines
Adobe Community Professional ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

No, it just counts how many fields have a value that isn't empty.

Do you want to add their actual values, ie sum them up?

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

i want to count all fields from 10 to 19 that have a value/text, the empty fields do not count.

The second script should count fields from 20 to 29 that have a certain text.

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

sorry if i don't express myself correctly, but my english is not the best

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

i want to count all fields from 10 to 19 that have a value/text, the empty fields do not count.

The script in my last post will do that.

The second script should count fields from 20 to 29 that have a certain text.

Alongside the 10-19 fields, or separately?

sorry if i don't express myself correctly, but my english is not the best

Your English is fine.

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

The script in my last post will do that.

i use this script and not works

  1. var count = 0
  2. for (var i=10; i<=19; i++) { 
  3.     if (this.getField("10"+i).valueAsString != "") count++; 
  4. event.value = count; 

Alongside the 10-19 fields, or separately?

separately

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Probably or rather, I'm making a mistake somewhere.

however, it's depressing, will continue tomorrow...thank you for your time and effort.

Any additional help is still welcome.

Thx

Niko

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Check the console for errors.

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

This is not the script from my last post...Take the code from your reply #14.

If it's not working there's probably an error. You should check the JS Console.

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
Participant ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Thx again all for your Help...now i solve the problem

Must've slept in to get the hang of it.

All well, thank you it was really a big help.

Wishes all a good and happy day, may everything work out

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
Participant ,
Aug 08, 2019 Aug 08, 2019

Copy link to clipboard

Copied

One last

Try to count the sum of the fields with certain text "E" together, without success.

-------------------------------------

var count = 0;

    for (var i=10; i<=19; i++) {

        if (this.getField(i).valueAsString != "E") count++;

    }

    event.value = count; 

-------------------------------------------

What am I doing wrong in the script?

Thx

Niko

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 ,
Aug 08, 2019 Aug 08, 2019

Copy link to clipboard

Copied

You're using the wrong opearator. "!=" means NOT EQUALS. You should be using "==", which is the EQUALS comparison operator in JS.

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
Participant ,
Aug 08, 2019 Aug 08, 2019

Copy link to clipboard

Copied

LATEST

You're not human... you're an angel

Thank you, now it has sparked

Have a nice day

Niko

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